MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / ucvector_reserve

Function ucvector_reserve

samples/shared/lodepng.cpp:218–232  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

216
217/*returns 1 if success, 0 if failure ==> nothing done*/
218static 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*/
235static 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