MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / ucvector_reserve

Function ucvector_reserve

samples/cgpu/cgpu-basic/mandelbrot/lodepng.c:214–228  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 2

ucvector_resizeFunction · 0.85
decodeGenericFunction · 0.85

Calls 1

lodepng_reallocFunction · 0.85

Tested by

no test coverage detected