From fcbe0443befdd5278d75189edf933dbd6c8512de Mon Sep 17 00:00:00 2001 From: natural-law Date: Mon, 11 Jul 2011 15:16:29 +0800 Subject: [PATCH] Resolve a bug in ZipUtils.cpp. And modify the Makefile of tests on wophone. --- cocos2dx/support/zip_support/ZipUtils.cpp | 9 ++++----- tests/test.wophone/Makefile.ARM | 4 ---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cocos2dx/support/zip_support/ZipUtils.cpp b/cocos2dx/support/zip_support/ZipUtils.cpp index 96983e99b4..481103cc0c 100644 --- a/cocos2dx/support/zip_support/ZipUtils.cpp +++ b/cocos2dx/support/zip_support/ZipUtils.cpp @@ -40,7 +40,7 @@ namespace cocos2d int err = Z_OK; int bufferSize = outLenghtHint; - *out = (unsigned char*) malloc(bufferSize); + *out = new unsigned char[bufferSize]; z_stream d_stream; /* decompression stream */ d_stream.zalloc = (alloc_func)0; @@ -78,17 +78,16 @@ namespace cocos2d // not enough memory ? if (err != Z_STREAM_END) { - unsigned char *tmp = (unsigned char*)realloc(*out, bufferSize * BUFFER_INC_FACTOR); + delete [] *out; + *out = new unsigned char[bufferSize * BUFFER_INC_FACTOR]; /* not enough memory, ouch */ - if (! tmp ) + if (! *out ) { CCLOG("cocos2d: ZipUtils: realloc failed"); inflateEnd(&d_stream); return Z_MEM_ERROR; } - /* only assign to *out if tmp is valid. it's not guaranteed that realloc will reuse the memory */ - *out = tmp; d_stream.next_out = *out + bufferSize; d_stream.avail_out = bufferSize; diff --git a/tests/test.wophone/Makefile.ARM b/tests/test.wophone/Makefile.ARM index b58a2514dd..24ea05b856 100644 --- a/tests/test.wophone/Makefile.ARM +++ b/tests/test.wophone/Makefile.ARM @@ -38,7 +38,6 @@ first: all OBJECTS = \ $(OBJECTS_DIR)/AppDelegate.o \ $(OBJECTS_DIR)/main.o \ - $(OBJECTS_DIR)/NewDeleteOp.o \ $(OBJECTS_DIR)/TG3AppDllEntry.o \ $(OBJECTS_DIR)/controller.o \ $(OBJECTS_DIR)/testBasic.o \ @@ -144,9 +143,6 @@ $(OBJECTS_DIR)/AppDelegate.o : ../AppDelegate.cpp $(OBJECTS_DIR)/main.o : ./main.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/main.o ./main.cpp -$(OBJECTS_DIR)/NewDeleteOp.o : ./NewDeleteOp.cpp - $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/NewDeleteOp.o ./NewDeleteOp.cpp - $(OBJECTS_DIR)/TG3AppDllEntry.o : ./TG3AppDllEntry.cpp $(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/TG3AppDllEntry.o ./TG3AppDllEntry.cpp