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

Function uivector_resize

depends/lodepng/lodepng.cpp:231–244  ·  view source on GitHub ↗

returns 1 if success, 0 if failure ==> nothing done*/

Source from the content-addressed store, hash-verified

229
230/*returns 1 if success, 0 if failure ==> nothing done*/
231static unsigned uivector_resize(uivector* p, size_t size) {
232 size_t allocsize = size * sizeof(unsigned);
233 if(allocsize > p->allocsize) {
234 size_t newsize = allocsize + (p->allocsize >> 1u);
235 void* data = lodepng_realloc(p->data, newsize);
236 if(data) {
237 p->allocsize = newsize;
238 p->data = (unsigned*)data;
239 }
240 else return 0; /*error: not enough memory*/
241 }
242 p->size = size;
243 return 1; /*success*/
244}
245
246static void uivector_init(uivector* p) {
247 p->data = NULL;

Callers 3

uivector_push_backFunction · 0.85
addLengthDistanceFunction · 0.85
deflateDynamicFunction · 0.85

Calls 1

lodepng_reallocFunction · 0.85

Tested by

no test coverage detected