From 57970da3989615ebbc39fca562f9b7bd1cb91cc5 Mon Sep 17 00:00:00 2001 From: lvlong Date: Tue, 27 Jan 2015 15:50:05 +0800 Subject: [PATCH] Do some optimize --- cocos/renderer/CCGLProgram.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index 3d2c3a3aec..ac5ee3ecfe 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -672,9 +672,8 @@ bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsign } else { - if (element->second.second != bytes){ - free(element->second.first); - GLvoid* value = malloc(bytes); + if (element->second.second < bytes){ + GLvoid* value = realloc(element->second.first, bytes); memcpy(value, data, bytes ); _hashForUniforms[location] = std::make_pair(value, bytes); }else