Update extension.h

#define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * COUNT, __FILE__, __LINE__))

It is a really dangerous macros here.
If use it like this "MALLOC(Type, n+2)", it will alloc sizeof(TYPE) * COUNT + 2 byte memory.but I want it alloc sizeof(TYPE) * (COUNT + 2) byte. It is a typical macro unwind error.
This commit is contained in:
ffskyfan 2015-06-05 12:14:27 +08:00
parent cb3b760759
commit b8a022238f
1 changed files with 1 additions and 1 deletions

View File

@ -32,7 +32,7 @@
#define SPINE_EXTENSION_H_
/* All allocation uses these. */
#define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * COUNT, __FILE__, __LINE__))
#define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * (COUNT), __FILE__, __LINE__))
#define CALLOC(TYPE,COUNT) ((TYPE*)_calloc(COUNT, sizeof(TYPE), __FILE__, __LINE__))
#define NEW(TYPE) CALLOC(TYPE,1)