| 2562 | } |
| 2563 | |
| 2564 | unsigned 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 |
| 2584 | set data or crc yet. Returns the start of the chunk in chunk. The start of |
no test coverage detected