MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / gfb_frame

Function gfb_frame

tests/test_test_impact_git.c:2279–2293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2277}
2278
2279static cbm_git_bytes_t gfb_frame(CBMArena *arena,const char *oid,const void *body,size_t length,
2280 bool payload) {
2281 char header[128];int n=snprintf(header,sizeof(header),"%s blob %zu\n",oid,length);
2282 if(n<=0 || (size_t)n>=sizeof(header) || length>SIZE_MAX-(size_t)n-1)
2283 return (cbm_git_bytes_t){NULL,0};
2284 size_t total=(size_t)n+(payload?length+1:0);
2285 unsigned char *bytes=cbm_arena_alloc(arena,total);
2286 if(!bytes)return (cbm_git_bytes_t){NULL,0};
2287 memcpy(bytes,header,(size_t)n);
2288 if(payload) {
2289 if(length)memcpy(bytes+n,body,length);
2290 bytes[total-1]='\n';
2291 }
2292 return (cbm_git_bytes_t){bytes,total};
2293}
2294
2295static cbm_git_bytes_t gfb_concat(CBMArena *arena,cbm_git_bytes_t a,cbm_git_bytes_t b) {
2296 if(a.length>SIZE_MAX-b.length)return (cbm_git_bytes_t){NULL,0};

Callers 1

Calls 1

cbm_arena_allocFunction · 0.50

Tested by

no test coverage detected