[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua list crashes with a linear allocator
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 19 Dec 2014 20:02:03 -0200
> static void* LuaAllocator( void* ud, void* ptr, size_t osize, size_t nsize )
> {
> linear_allocator_t* lalloc = (linear_allocator_t*)ud;
> void* nptr = 0;
>
> if ( nsize != 0 )
> {
> if ( osize < nsize )
> {
> nptr = linear_allocator_malloc( lalloc, nsize );
> }
> else
> {
> nptr = ptr;
> }
> }
> [...]
> return nptr;
> }
When growing a block, shouldn't you copy the contents of the old block
to the new one?
-- Roberto