Lindenii Project Forge
Warning: Due to various recent migrations, viewing non-HEAD refs may be broken.
/git/obj_blob.ha (raw)
// A simple Git blob with its object ID and raw data.
export type blob = struct {
oid: oid,
data: []u8,
};
// Frees resources associated with a [[blob]].
export fn blob_finish(b: blob) void = {
free(b.data);
};
// Parses a blob from its raw data and object ID.
// The data is copied and the resulting blob
// must be finished with [[blob_finish]].
export fn parse_blob(id: oid, body: []u8) (blob | nomem) = {
let data = alloc(body...)?;
return blob { oid = id, data = data };
};