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

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:765:    io->len+=2;    }       static void io_append_int_uc( Buffer *io, unsigned INT32 i )    {    *((INT32 *)(io->buffer+io->len)) = htonl(i);    io->len+=4;    }       -  static size_t io_svalue_len( Buffer *UNUSED(io), struct svalue *p ) +  static size_t io_svalue_len( Buffer *io, struct svalue *p )    { -  if( TYPEOF(*p) == PIKE_T_STRING ) -  { +  switch( TYPEOF(*p) ) { +  case PIKE_T_INT: +  return 1; +  case PIKE_T_STRING:    if( !p->u.string->size_shift )    return p->u.string->len; -  +  break; +  case PIKE_T_ARRAY: { +  size_t len; +  struct array *argp = p->u.array; +  INT_TYPE i; +  DECLARE_CYCLIC(); +  +  if (BEGIN_CYCLIC(io, argp)) +  Pike_error("Attempt to append a cyclic array to a buffer.\n"); +  +  for(len=i=0; i<argp->size; i++ ) +  len += io_svalue_len( io, argp->item+i ); +  +  END_CYCLIC(); +  return len;    } -  if( TYPEOF(*p) == PIKE_T_OBJECT ) -  { +  case PIKE_T_OBJECT: {    size_t len;    if( get_memory_object_memory( p->u.object, NULL, &len, NULL ) )    return len; -  +  break;    } -  +  }    Pike_error("Illegal argument (not an 8bit string or 8bit buffer object)\n");    }       /* NOTE: Can return negative integers. */    static INT_TYPE get_small_int( struct svalue *s )    ATTRIBUTE((noclone,noinline));       static INT_TYPE get_small_int( struct svalue *s )    {    if( LIKELY(TYPEOF(*s) == PIKE_T_INT) )