lua-users home
lua-l archive

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


Hello Olivier,

Friday, February 17, 2006, 6:42:49 PM, you wrote:

OD> ptr first

so, realloc(0,0) == malloc(0) not free(0) ?
my problem is lua doesn't free the pointer return by realloc(0,0)

OD> On 2/17/06, cloudwu <cloudwu@163.com> wrote:
>>
>> Hello Olivier,
>>
>> Friday, February 17, 2006, 5:35:32 PM, you wrote:
>>
>> OD> On 2/17/06, Olivier Delannoy <olivier.delannoy@gmail.com> wrote:
>> >> realloc does exactly the same as free in C standard.
>> >>
>> OD> in case of reallocation to a size of 0 ;)
>>
>> http://www.opengroup.org/onlinepubs/009695399/functions/realloc.html
>>
>> "If ptr is a null pointer, realloc() shall be equivalent to malloc()
>> for the specified size."
>>
>> ptr first or size first ?
>>
>> >> On 2/17/06, cloudwu <cloudwu@163.com> wrote:
>> >> >
>> >> > Hello Lua,
>> >> >
>> >> >       When I use my own allocator with lua 5.1, I found a memory leak.
>> >> >       lua call the allocator with all the arguments 0 .
>> >> >       My allocator, my_realloc(0,0), will return a unique pointer.
>> >> >       maybe lua need it return NULL, because I found lua never free
>> >> >       this unique pointer anymore.
>> >> >
>> >> >       Is it my allocator's bug?
>> >> >
>> >> > --
>> >> > Best regards,
>> >> >  cloudwu                          mailto:cloudwu@163.com
>> >> >             http://www.codingnow.com
>> >> >
>> >> > [失去, 总令人舍不得, 但痛苦并不来自于失去, 而是来自于我们不肯放手]
>> >> >
>> >> >
>> >> >
>> >>
>>
>>
>>
>> --
>> Best regards,
>>  cloudwu                            mailto:cloudwu@163.com
>>             http://www.codingnow.com
>>
>> [我们的慷慨决不应超出我们的能力]
>>
>>
>>



-- 
Best regards,
 cloudwu                            mailto:cloudwu@163.com
            http://www.codingnow.com

[未来属于不满足的人]