Merge pull request #159 from SmilyOrg/nanovg-allocPaths-fix
Merged fixed allocation for paths from nanovg
This commit is contained in:
commit
2805e1de41
@ -763,10 +763,13 @@ namespace
|
|||||||
static int glnvg__allocPaths(struct GLNVGcontext* gl, int n)
|
static int glnvg__allocPaths(struct GLNVGcontext* gl, int n)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (gl->npaths+n > gl->cpaths)
|
if (gl->npaths + n > gl->cpaths) {
|
||||||
{
|
GLNVGpath* paths;
|
||||||
gl->cpaths = gl->cpaths == 0 ? glnvg__maxi(n, 32) : gl->cpaths * 2;
|
int cpaths = glnvg__maxi(gl->npaths + n, 128) + gl->cpaths / 2; // 1.5x Overallocate
|
||||||
gl->paths = (struct GLNVGpath*)realloc(gl->paths, sizeof(struct GLNVGpath) * gl->cpaths);
|
paths = (GLNVGpath*)realloc(gl->paths, sizeof(GLNVGpath) * cpaths);
|
||||||
|
if (paths == NULL) return -1;
|
||||||
|
gl->paths = paths;
|
||||||
|
gl->cpaths = cpaths;
|
||||||
}
|
}
|
||||||
ret = gl->npaths;
|
ret = gl->npaths;
|
||||||
gl->npaths += n;
|
gl->npaths += n;
|
||||||
|
Loading…
Reference in New Issue
Block a user