src/mcp.c
/*
 * *************************************************************
 * Auto-resize memory allocation.
 */
Auto-resize memory allocation.
Auto - resize memory allocation .
mc_bool_t mcp_default_resizer( mcp_p aa, mc_size_t newsize )
{
  if ( newsize > aa->size )
    {
      while ( newsize > aa->size )
        aa->size = aa->size*2;
      mcp_resize_to( aa, aa->size );
      return mc_true;
    }
  else if ( newsize < aa->size/2 )
    {
      while ( ( aa->size / 2 ) >= 1 &&
              ( aa->size / 2 ) > newsize )
        aa->size /= 2;
      mcp_resize_to( aa, aa->size );
      return mc_true;
    }
  else
    return mc_false;
}
mc_bool_t mcp_default_resizer ( mcp_p aa , mc_size_t newsize ) { if ( newsize > aa -> size ) { while ( newsize > aa -> size ) aa -> size = aa -> size * 2 ; mcp_resize_to ( aa , aa -> size ) ; return mc_true ; } else if ( newsize < aa -> size / 2 ) { while ( ( aa -> size / 2 ) >= 1 && ( aa -> size / 2 ) > newsize ) aa -> size /= 2 ; mcp_resize_to ( aa , aa -> size ) ; return mc_true ; } else return mc_false ; }
Auto-resize memory allocation.
Auto - resize memory allocation .
/* Ensure that size is same or more than 1 and ensure that size is
         always bigger than aa->used. */