ext/iodine/fio.c
/**
 * Re-allocates memory. An attept to avoid copying the data is made only for big
 * memory allocations.
 *
 * This variation is slightly faster as it might copy less data
 */
Re-allocates memory. An attept to avoid copying the data is made only for big
memory allocations.

This variation is slightly faster as it might copy less data
Re - allocates memory . An attept to avoid copying the data is made only for big memory allocations . This variation is slightly faster as it might copy less data
void *fio_realloc2(void *ptr, size_t new_size, size_t copy_length) {
  if (!ptr || ptr == (void *)&on_malloc_zero) {
    return fio_malloc(new_size);
  }
  if (!new_size) {
    goto zero_size;
  }
  if (((uintptr_t)ptr & FIO_MEMORY_BLOCK_MASK) == 16) {
    return big_realloc(ptr, new_size);
  }
  void *new_mem = fio_malloc(new_size);
  if (!new_mem)
    return NULL;
  new_size = ((new_size >> 4) + (!!(new_size & 15)));
  copy_length = ((copy_length >> 4) + (!!(copy_length & 15)));
  fio_memcpy(new_mem, ptr, copy_length > new_size ? new_size : copy_length);
  block_slice_free(ptr);
  return new_mem;
zero_size:
  fio_free(ptr);
  return fio_malloc(0);
}
void * fio_realloc2 ( void * ptr , size_t new_size , size_t copy_length ) { if ( ! ptr || ptr == ( void * ) & on_malloc_zero ) { return fio_malloc ( new_size ) ; } if ( ! new_size ) { goto zero_size ; } if ( ( ( uintptr_t ) ptr & FIO_MEMORY_BLOCK_MASK ) == 16 ) { return big_realloc ( ptr , new_size ) ; } void * new_mem = fio_malloc ( new_size ) ; if ( ! new_mem ) return NULL ; new_size = ( ( new_size >> 4 ) + ( ! ! ( new_size & 15 ) ) ) ; copy_length = ( ( copy_length >> 4 ) + ( ! ! ( copy_length & 15 ) ) ) ; fio_memcpy ( new_mem , ptr , copy_length > new_size ? new_size : copy_length ) ; block_slice_free ( ptr ) ; return new_mem ; zero_size : fio_free ( ptr ) ; return fio_malloc ( 0 ) ; }
Re-allocates memory.
Re - allocates memory .
/* big reallocation - direct from the system */ /* allocated within block - don't even try to expand the allocation */ /* ceiling for 16 byte alignement, translated to 16 byte units */