MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__zexpand

Function stbi__zexpand

include/stb/stb_image.h:4273–4293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4271}
4272
4273static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes
4274{
4275 char *q;
4276 unsigned int cur, limit, old_limit;
4277 z->zout = zout;
4278 if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG");
4279 cur = (unsigned int) (z->zout - z->zout_start);
4280 limit = old_limit = (unsigned) (z->zout_end - z->zout_start);
4281 if (UINT_MAX - cur < (unsigned) n) return stbi__err("outofmem", "Out of memory");
4282 while (cur + n > limit) {
4283 if(limit > UINT_MAX / 2) return stbi__err("outofmem", "Out of memory");
4284 limit *= 2;
4285 }
4286 q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit);
4287 STBI_NOTUSED(old_limit);
4288 if (q == NULL) return stbi__err("outofmem", "Out of memory");
4289 z->zout_start = q;
4290 z->zout = q + cur;
4291 z->zout_end = q + limit;
4292 return 1;
4293}
4294
4295static const int stbi__zlength_base[31] = {
4296 3,4,5,6,7,8,9,10,11,13,

Callers 2

Calls 1

stbi__errFunction · 0.85

Tested by

no test coverage detected