[LINUX] Fix a compilation error in spine/extension.cpp.

This commit is contained in:
James Chen 2013-06-08 17:22:49 +08:00
parent ab15cd8c7b
commit 646d0aa1cf
1 changed files with 8 additions and 3 deletions

View File

@ -53,6 +53,7 @@ void _setFree (void (*free) (void* ptr)) {
char* _readFile (const char* path, int* length) {
char *data;
FILE *file = fopen(path, "rb");
int readBytes = 0;
if (!file) return 0;
fseek(file, 0, SEEK_END);
@ -60,10 +61,14 @@ char* _readFile (const char* path, int* length) {
fseek(file, 0, SEEK_SET);
data = MALLOC(char, *length);
fread(data, 1, *length, file);
readBytes = fread(data, 1, *length, file);
fclose(file);
if (readBytes != *length)
{
FREE(data);
data = NULL;
}
return data;
}
}} // namespace cocos2d { namespace extension {
}} // namespace cocos2d { namespace extension {