Merge pull request #378 from natural-law/master

Resolve a bug in ZipUtils.cpp
This commit is contained in:
minggo 2011-07-11 00:28:48 -07:00
commit c0efe58c2a
2 changed files with 4 additions and 9 deletions

View File

@ -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;

View File

@ -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