mirror of
https://github.com/samba-team/samba.git
synced 2025-12-12 12:23:50 +03:00
Made talloc_realloc() semantics match realloc(). JF was complaining :-).
realloc(NULL) == malloc. realloc(p,0) == free() - a no-op in talloc. Jeremy.
This commit is contained in:
@@ -80,6 +80,14 @@ void *talloc_realloc(TALLOC_CTX *t, void *ptr, size_t size)
|
|||||||
{
|
{
|
||||||
struct talloc_chunk *tc;
|
struct talloc_chunk *tc;
|
||||||
|
|
||||||
|
/* size zero is equivalent to free() */
|
||||||
|
if (size == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* realloc(NULL) is equavalent to malloc() */
|
||||||
|
if (ptr == NULL)
|
||||||
|
return talloc(t, size);
|
||||||
|
|
||||||
for (tc=t->list; tc; tc=tc->next) {
|
for (tc=t->list; tc; tc=tc->next) {
|
||||||
if (tc->ptr == ptr) {
|
if (tc->ptr == ptr) {
|
||||||
ptr = realloc(ptr, size);
|
ptr = realloc(ptr, size);
|
||||||
|
|||||||
Reference in New Issue
Block a user