MCPcopy Create free account
hub / github.com/DFHack/dfhack / lodepng_chunk_append

Function lodepng_chunk_append

depends/lodepng/lodepng.cpp:2564–2581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2562}
2563
2564unsigned lodepng_chunk_append(unsigned char** out, size_t* outsize, const unsigned char* chunk) {
2565 unsigned i;
2566 size_t total_chunk_length, new_length;
2567 unsigned char *chunk_start, *new_buffer;
2568
2569 if(lodepng_addofl(lodepng_chunk_length(chunk), 12, &total_chunk_length)) return 77;
2570 if(lodepng_addofl(*outsize, total_chunk_length, &new_length)) return 77;
2571
2572 new_buffer = (unsigned char*)lodepng_realloc(*out, new_length);
2573 if(!new_buffer) return 83; /*alloc fail*/
2574 (*out) = new_buffer;
2575 (*outsize) = new_length;
2576 chunk_start = &(*out)[new_length - total_chunk_length];
2577
2578 for(i = 0; i != total_chunk_length; ++i) chunk_start[i] = chunk[i];
2579
2580 return 0;
2581}
2582
2583/*Sets length and name and allocates the space for data and crc but does not
2584set data or crc yet. Returns the start of the chunk in chunk. The start of

Callers 2

decodeGenericFunction · 0.85
addUnknownChunksFunction · 0.85

Calls 3

lodepng_addoflFunction · 0.85
lodepng_chunk_lengthFunction · 0.85
lodepng_reallocFunction · 0.85

Tested by

no test coverage detected