lua-users home
lua-l archive

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

> I think it's a solution, but I still have a question.
> >void *newptr = realloc(ptr, nsize);
> >   if (newptr == NULL && ptr != NULL && nsize <= osize)
> >      return ptr;  /* keep the original block */
> If it runs into such code path.
> Which value would you pass to the l_alloc function when invoking it
> next time,  nsize or osize(i.e. nsize <= osize)?
> You don't exactly know whether the expression (i.e. newptr == NULL &&
> ptr != NULL && nsize <= osize) is true or not (when this function was
> called last time).

I assume your question is about the 'osize' value . As the contract
says, 'osize' will be the 'nsize' passed in the previous call.  Note
that 'osize' is not used by 'realloc', so its value is irrelevant in this
standard implementation of 'l_alloc'.

-- Roberto