MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / lodepng_chunk_append

Function lodepng_chunk_append

dependency/densecrf/examples/lodepng.cpp:2493–2510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2491}
2492
2493unsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk)
2494{
2495 unsigned i;
2496 unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12;
2497 unsigned char *chunk_start, *new_buffer;
2498 size_t new_length = (*outlength) + total_chunk_length;
2499 if(new_length < total_chunk_length || new_length < (*outlength)) return 77; /*integer overflow happened*/
2500
2501 new_buffer = (unsigned char*)lodepng_realloc(*out, new_length);
2502 if(!new_buffer) return 83; /*alloc fail*/
2503 (*out) = new_buffer;
2504 (*outlength) = new_length;
2505 chunk_start = &(*out)[new_length - total_chunk_length];
2506
2507 for(i = 0; i != total_chunk_length; ++i) chunk_start[i] = chunk[i];
2508
2509 return 0;
2510}
2511
2512unsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length,
2513 const char* type, const unsigned char* data)

Callers 2

decodeGenericFunction · 0.85
addUnknownChunksFunction · 0.85

Calls 2

lodepng_chunk_lengthFunction · 0.85
lodepng_reallocFunction · 0.85

Tested by

no test coverage detected