lua-users home
lua-l archive

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

On Nov 30, 2014, at 10:53 PM, Thomas Jericke <> wrote:

Yeah that's true for Lua 5.2 and as I use that version so I should have known it. My code still should work for Lua 5.1 as there the reference states "ptr is NULL if and only if osize is zero".

And I don't know why casting a void* to a stuct pointer is safer than casting it to anything else. It's unsafe either way.

I think the correct way to view this is if ptr is NULL then osize cannot mean the sizeof the “old” allocation since this has no meaning when size is NULL. So in 5.1 osize is undefined when ptr is NULL, while in 5.2 osize when ptr is NULL has additional semantics.