[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Are there some potential problems if I use a self-defined memory acquirement function instead of realloc(3) in the l_alloc function?
- From: 孙世龙 sunshilong <sunshilong369@...>
- Date: Mon, 10 Aug 2020 16:32:27 +0800
Hi, list
I want to use a self-defined memory acquirement function instead of
using realloc(3) in the l_alloc function.
Since I am a newbie, I don't know if there are some potential problems.
Could somebody shed some light on this problem?
Thank you for your attention to this matter.
For your convenience, here is the original l_alloc() function for lua.
static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
(void)ud; (void)osize; /* not used */
if (nsize == 0) {
free(ptr);
return NULL;
}
else
return realloc(ptr, nsize);
}
Best regards.
Sunshilong