Branch: Tag:

2015-05-16

2015-05-16 13:02:23 by Tobias S. Josefowitz <tobij@tobij.de>

Stdio.Buffer: xrealloc() now throws on realloc() failure.

279:    if( UNLIKELY(io->len + bytes > io->allocated) )    {    size_t new_len = io->allocated; -  void *new_ptr; +        do    new_len = ((new_len+32)*2)-32;    while( new_len < io->len + bytes );    -  new_ptr = xrealloc( io->buffer, new_len ); -  if( !new_ptr ) -  Pike_error(msg_out_of_mem_2, new_len ); -  io->buffer = new_ptr; +  io->buffer = xrealloc( io->buffer, new_len );    io->num_malloc++;    io->allocated = new_len;    }
2078:    PIKEFUN void trim( )    {    Buffer *io = THIS; -  void *new_ptr; +        io_add_space( io, 0, 1 );    if( io->allocated > io->len+32 )    { -  new_ptr = xrealloc( io->buffer, io->len ); -  if (new_ptr) -  Pike_error(msg_out_of_mem_2, io->len); -  io->buffer = new_ptr; +  io->buffer = xrealloc( io->buffer, io->len );    io->num_malloc++;    io->allocated = io->len;    }