0f31d51743
A blob is a piece of data of variable length that belongs in a blob list while a data stream is a buffer used to move data between blobs among other things. Signed-off-by: Chloe M. <chloe@mirocom.org>
26 lines
495 B
C
26 lines
495 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;
|
|
if (stmp == NULL) {
|
|
bp->data = NULL;
|
|
} else {
|
|
bp->data = xmalloc(stmp->length);
|
|
memcpy(bp->data, stmp->data, stmp->length);
|
|
}
|
|
|
|
return bp;
|
|
}
|