mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-27 12:11:22 +08:00
[cocos2d-x] Closes #650, don't deep copy data read from file on cocos2d-x 3.12+
This commit is contained in:
parent
2b29f9b5b6
commit
819bb4cf0c
@ -82,8 +82,15 @@ char* _spUtil_readFile (const char* path, int* length) {
|
|||||||
if (data.isNull()) return 0;
|
if (data.isNull()) return 0;
|
||||||
|
|
||||||
// avoid buffer overflow (int is shorter than ssize_t in certain platforms)
|
// avoid buffer overflow (int is shorter than ssize_t in certain platforms)
|
||||||
|
#if COCOS2D_VERSION >= 0x00031200
|
||||||
ssize_t tmpLen;
|
ssize_t tmpLen;
|
||||||
char *ret = (char*)data.takeBuffer(&tmpLen);
|
char *ret = (char*)data.takeBuffer(&tmpLen);
|
||||||
*length = static_cast<int>(tmpLen);
|
*length = static_cast<int>(tmpLen);
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
*length = static_cast<int>(data.getSize());
|
||||||
|
char* bytes = MALLOC(char, *length);
|
||||||
|
memcpy(bytes, data.getBytes(), *length);
|
||||||
|
return bytes;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user