pike.git / src / modules / _Stdio / buffer.cmod

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:75:    *!    */   PIKECLASS Buffer    /* This is needed to get consisten behavior in case this    * buffer is a sub-buffer, in which case the source    * buffer needs to be unlocked as soon as possible.    */    program_flags PROGRAM_DESTRUCT_IMMEDIATE;   {   #if PRECOMPILE_API_VERSION > 5 + #ifdef PIKE_DEBUG    PIKEVAR int b.num_malloc;    PIKEVAR int b.num_move;   #endif -  + #endif       CVAR Buffer b;       EXTRA    {    PIKE_MAP_VARIABLE("__output", OFFSETOF(Buffer_struct, b.output),    tMix, PIKE_T_MIXED, ID_PRIVATE|ID_HIDDEN|ID_PROTECTED);    }      
pike.git/src/modules/_Stdio/buffer.cmod:140:    }    return 0;    }       static void io_discard_bufstart( Buffer *io )    {    if ( LIKELY(!io->locked_move) )    {    memmove( io->buffer, io_read_pointer(io), io_len(io) );    io->len -= io->offset; + #ifdef PIKE_DEBUG    io->num_move++; -  + #endif    io->offset = 0;    }    }       PMOD_EXPORT void io_trim( Buffer *io )    {    if( io->allocated && (io->offset > 64 || io->len > 64) && !io->locked)    {    if( io->offset > 64 && io->offset > io_len(io) )    io_discard_bufstart(io);       if( io->len > 64 && ((io->allocated > (io->len)*(1.0+io->max_waste))))    {    io->buffer = xrealloc( io->buffer, io->len ); -  + #ifdef PIKE_DEBUG    io->num_malloc++; -  + #endif    io->allocated = io->len;    }    }    }       static void io_unlink_external_storage( Buffer *io )    ATTRIBUTE((noclone,noinline));       static void io_unlink_external_storage( Buffer *io )    {
pike.git/src/modules/_Stdio/buffer.cmod:199:       headroom += io->len - io->offset;       if (headroom < io->len - io->offset)    Pike_error(msg_out_of_mem_2, headroom);       io->buffer = xalloc( headroom );    io->allocated = headroom;    io->len -= io->offset;    io->offset = 0; + #ifdef PIKE_DEBUG    io->num_malloc++; -  + #endif    memcpy( io->buffer, old, io->len );    io_unlink_external_storage(io);    }    }       static struct object *    io_read_buffer( Buffer *io, size_t len, int do_copy, size_t headroom )    ATTRIBUTE((noclone,noinline));       PMOD_EXPORT unsigned char *io_add_space_do_something( Buffer *io, size_t bytes, int force )
pike.git/src/modules/_Stdio/buffer.cmod:282:    newbuffer->buffer = io->buffer;    io->buffer = cbuf;    io->len = newbuffer->len;    io->offset = 0;    io->allocated = newbuffer->allocated;    io->this = newobj;    newbuffer->this = oldobj;    io->max_waste = newbuffer->max_waste;    } else {    io->buffer = xrealloc( io->buffer, io->allocated + growth ); + #ifdef PIKE_DEBUG    io->num_malloc++; -  + #endif    io->allocated += growth;    }    }    return io->buffer+io->len;    }       /*! @decl protected bool range_error( int howmuch )    *!    *! This function is called when an attempt is made to read out of bounds.    *!