瀏覽代碼

Merge branch 'master' of github.com:bkaradzic/bgfx

Branimir Karadžić 11 年之前
父節點
當前提交
6be21f05db
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      examples/common/nanovg/nanovg_bgfx.cpp

+ 7 - 4
examples/common/nanovg/nanovg_bgfx.cpp

@@ -763,10 +763,13 @@ namespace
 	static int glnvg__allocPaths(struct GLNVGcontext* gl, int n)
 	{
 		int ret = 0;
-		if (gl->npaths+n > gl->cpaths)
-		{
-			gl->cpaths = gl->cpaths == 0 ? glnvg__maxi(n, 32) : gl->cpaths * 2;
-			gl->paths = (struct GLNVGpath*)realloc(gl->paths, sizeof(struct GLNVGpath) * gl->cpaths);
+		if (gl->npaths + n > gl->cpaths) {
+			GLNVGpath* paths;
+			int cpaths = glnvg__maxi(gl->npaths + n, 128) + gl->cpaths / 2; // 1.5x Overallocate
+			paths = (GLNVGpath*)realloc(gl->paths, sizeof(GLNVGpath) * cpaths);
+			if (paths == NULL) return -1;
+			gl->paths = paths;
+			gl->cpaths = cpaths;
 		}
 		ret = gl->npaths;
 		gl->npaths += n;