Introduce mem_size() and New() and start using it.

This commit is contained in:
Markus F.X.J. Oberhumer
2016-09-20 15:24:07 +02:00
parent 8d433f2580
commit 44248f19b5
8 changed files with 102 additions and 65 deletions
+1 -2
View File
@@ -297,8 +297,7 @@ inline const T& UPX_MIN(const T& a, const T& b) { if (a < b) return a; return b;
// An Array allocates memory on the heap, but automatically
// gets destructed when leaving scope or on exceptions.
#define Array(type, var, size) \
assert((int)(size) > 0); \
MemBuffer var ## _membuf((size)*(sizeof(type))); \
MemBuffer var ## _membuf(mem_size(sizeof(type), size)); \
type * const var = ((type *) var ## _membuf.getVoidPtr())
#define ByteArray(var, size) Array(unsigned char, var, size)