Files
blobchain/core/blob_subr.c
T
2026-04-30 21:11:42 -04:00

27 lines
516 B
C

/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause
*/
#include <string.h>
#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);
}
return bp;
}