lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 10.05.2016 um 10:13 schröbte gz@tset.de:

Well, in the real code the allocations are made for user supplied
parameters, so I don't
know neither the size of the parameters not their count (which can be
up to 65535), so
I really need to allocate the memory.

how about C99 variable length arrays? C99 is available almost everywhere
by now, given that it is 17 years old, and var arrays seem to do exactly
what you want with added leakage prevention.

There are still very old compilers (*cough* Visual C *cough*) that don't support it, and there probably will be very new compilers that won't support it either, because it is now an optional feature in the current ISO C standard (2011). Also it has bad behavior when an allocation request cannot be fulfilled.

Philipp