Logo Search packages:      
Sourcecode: samba-doc-ja version File versions

void* talloc_realloc ( TALLOC_CTX t,
void *  ptr,
size_t  size 
)

A talloc version of realloc

Definition at line 183 of file talloc.c.

References talloc_chunk::next, talloc_chunk::ptr, talloc_chunk::size, and talloc().

Referenced by talloc_vasprintf_append().

{
      struct talloc_chunk *tc;
      void *new_ptr;

      /* size zero is equivalent to free() */
      if (!t || 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) {
            if (tc->ptr == ptr) {
                  new_ptr = Realloc(ptr, size);
                  if (new_ptr) {
                        t->total_alloc_size += (size - tc->size);
                        tc->size = size;
                        tc->ptr = new_ptr;
                  }
                  return new_ptr;
            }
      }
      return NULL;
}


Generated by  Doxygen 1.6.0   Back to index