/* * Copyright (c) 2026, Chloe M. * Provided under the BSD-3 clause */ #include #include "blobchain/blob.h" #include "blobchain/memlib.h" struct blob * blob_allocate(struct data_stream *stmp) { struct blob *bp; bp = xmalloc(sizeof(*bp)); bp->length = (stmp != NULL) ? stmp->length : 0; bp->next = NULL; if (stmp == NULL) { bp->data = NULL; } else { bp->data = xmalloc(stmp->length); memcpy(bp->data, stmp->data, stmp->length); } memcpy(bp->hash, stmp->hash, SHA256_N_BYTES); return bp; }