returns 1 if success, 0 if failure ==> nothing done*/
| 216 | |
| 217 | /*returns 1 if success, 0 if failure ==> nothing done*/ |
| 218 | static unsigned ucvector_reserve(ucvector* p, size_t allocsize) |
| 219 | { |
| 220 | if(allocsize > p->allocsize) |
| 221 | { |
| 222 | size_t newsize = (allocsize > p->allocsize * 2) ? allocsize : (allocsize * 3 / 2); |
| 223 | void* data = lodepng_realloc(p->data, newsize); |
| 224 | if(data) |
| 225 | { |
| 226 | p->allocsize = newsize; |
| 227 | p->data = (unsigned char*)data; |
| 228 | } |
| 229 | else return 0; /*error: not enough memory*/ |
| 230 | } |
| 231 | return 1; |
| 232 | } |
| 233 | |
| 234 | /*returns 1 if success, 0 if failure ==> nothing done*/ |
| 235 | static unsigned ucvector_resize(ucvector* p, size_t size) |
no test coverage detected