mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-10-31 13:10:35 +00:00
Introduce whine_realloc
Move few patters with whine_malloc, if (successful) copy+free, to a new whine_realloc. It should do the same thing, but with a help from OS it can avoid unnecessary copy and free if allocation of more data after current data is possible. Added few setting remanining space to 0, because realloc does not use calloc like whine_malloc does. There is no advantage of zeroing what we will immediately overwrite. Zero only remaining space.
This commit is contained in:
1 parent
ba4c7d906b
commit
0666ae3d27
6 files changed
+24
-24
No files matched your search
+10
@@ -336,6 +336,16 @@ void *whine_malloc(size_t size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *whine_realloc(void *ptr, size_t size)
|
||||
{
|
||||
void *ret = realloc(ptr, size);
|
||||
|
||||
if (!ret)
|
||||
my_syslog(LOG_ERR, _("failed to reallocate %d bytes"), (int) size);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sockaddr_isequal(const union mysockaddr *s1, const union mysockaddr *s2)
|
||||
{
|
||||
if (s1->sa.sa_family == s2->sa.sa_family)
|
||||
|
||||
Reference in new issue
Block a user