MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / lodepng_chunk_append

Function lodepng_chunk_append

samples/shared/lodepng.cpp:2458–2475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2456}
2457
2458unsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk)
2459{
2460 unsigned i;
2461 unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12;
2462 unsigned char *chunk_start, *new_buffer;
2463 size_t new_length = (*outlength) + total_chunk_length;
2464 if(new_length < total_chunk_length || new_length < (*outlength)) return 77; /*integer overflow happened*/
2465
2466 new_buffer = (unsigned char*)lodepng_realloc(*out, new_length);
2467 if(!new_buffer) return 83; /*alloc fail*/
2468 (*out) = new_buffer;
2469 (*outlength) = new_length;
2470 chunk_start = &(*out)[new_length - total_chunk_length];
2471
2472 for(i = 0; i < total_chunk_length; i++) chunk_start[i] = chunk[i];
2473
2474 return 0;
2475}
2476
2477unsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length,
2478 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