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

Function lodepng_chunk_next

depends/lodepng/lodepng.cpp:2516–2530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2514}
2515
2516unsigned char* lodepng_chunk_next(unsigned char* chunk, unsigned char* end) {
2517 if(chunk >= end || end - chunk < 12) return end; /*too small to contain a chunk*/
2518 if(chunk[0] == 0x89 && chunk[1] == 0x50 && chunk[2] == 0x4e && chunk[3] == 0x47
2519 && chunk[4] == 0x0d && chunk[5] == 0x0a && chunk[6] == 0x1a && chunk[7] == 0x0a) {
2520 /* Is PNG magic header at start of PNG file. Jump to first actual chunk. */
2521 return chunk + 8;
2522 } else {
2523 size_t total_chunk_length;
2524 unsigned char* result;
2525 if(lodepng_addofl(lodepng_chunk_length(chunk), 12, &total_chunk_length)) return end;
2526 result = chunk + total_chunk_length;
2527 if(result < chunk) return end; /*pointer overflow*/
2528 return result;
2529 }
2530}
2531
2532const unsigned char* lodepng_chunk_next_const(const unsigned char* chunk, const unsigned char* end) {
2533 if(chunk >= end || end - chunk < 12) return end; /*too small to contain a chunk*/

Callers 2

lodepng_chunk_findFunction · 0.85
addUnknownChunksFunction · 0.85

Calls 2

lodepng_addoflFunction · 0.85
lodepng_chunk_lengthFunction · 0.85

Tested by

no test coverage detected