MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / ucvector_reserve

Function ucvector_reserve

dependency/densecrf/examples/lodepng.cpp:213–227  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

211
212/*returns 1 if success, 0 if failure ==> nothing done*/
213static unsigned ucvector_reserve(ucvector* p, size_t allocsize)
214{
215 if(allocsize > p->allocsize)
216 {
217 size_t newsize = (allocsize > p->allocsize * 2) ? allocsize : (allocsize * 3 / 2);
218 void* data = lodepng_realloc(p->data, newsize);
219 if(data)
220 {
221 p->allocsize = newsize;
222 p->data = (unsigned char*)data;
223 }
224 else return 0; /*error: not enough memory*/
225 }
226 return 1;
227}
228
229/*returns 1 if success, 0 if failure ==> nothing done*/
230static unsigned ucvector_resize(ucvector* p, size_t size)

Callers 2

ucvector_resizeFunction · 0.85
lodepng.cppFile · 0.85

Calls 1

lodepng_reallocFunction · 0.85

Tested by

no test coverage detected