pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:8:   #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "mapping.h"   #include "array.h"   #include "multiset.h"   #include "lex.h" - #include "dynamic_buffer.h" + #include "buffer.h"   #include "pike_error.h"   #include "operators.h"   #include "builtin_functions.h"   #include "module_support.h"   #include "fsort.h"   #include "threads.h"   #include "version.h"   #include "bignum.h"   #include "pikecode.h"   #include "pike_types.h"
pike.git/src/encode.c:153:   struct encode_data   {    int canonic;    struct object *codec;    struct svalue counter;    struct mapping *encoded;    /* The encoded mapping maps encoded things to their entry IDs. A    * value less than COUNTER_START means that it's a forward reference    * to a thing not yet encoded. */    struct array *delayed; -  dynamic_buffer buf; +  struct byte_buffer buf;   #ifdef ENCODE_DEBUG    int debug, depth;   #endif   };      static struct object *encoder_codec (struct encode_data *data)   {    struct pike_string *encoder_str;    if (data->codec) return data->codec;    MAKE_CONST_STRING (encoder_str, "Encoder");    return data->codec = lookup_codec (encoder_str);   }      /* Convert to/from forward reference ID. */   #define CONVERT_ENTRY_ID(ID) (-((ID) - COUNTER_START) - (-COUNTER_START + 1))      static void encode_value2(struct svalue *val, struct encode_data *data, int force_encode);    - #define addstr(s, l) low_my_binary_strcat((s), (l), &(data->buf)) - #define addchar(t) low_my_putchar((char)(t), &(data->buf)) + #define addstr(s, l) buffer_memcpy(&(data->buf), (s), (l)) + #define addchar(t) buffer_add_char(&(data->buf), (char)(t))   #define addchar_unsafe(t) buffer_add_char_unsafe(&(data->buf), t)      /* Code a pike string */      #if PIKE_BYTEORDER == 4321   #define ENCODE_DATA(S) \    addstr( (S)->str, (S)->len << (S)->size_shift );   #else   #define ENCODE_DATA(S) do { \    buffer_ensure_space(&(data->buf), (S)->len << (S)->size_shift); \
pike.git/src/encode.c:1685:      encode_done:;      #ifdef ENCODE_DEBUG    data->depth -= 2;   #endif   }      static void free_encode_data(struct encode_data *data)   { -  toss_buffer(& data->buf); +  buffer_free(& data->buf);    if (data->codec) free_object (data->codec);    free_mapping(data->encoded);    free_array(data->delayed);   }      /*! @decl string encode_value(mixed value, Codec|void codec)    *!    *! Code a value into a string.    *!    *! This function takes a value, and converts it to a string. This string
pike.git/src/encode.c:1747: Inside #if defined(ENCODE_DEBUG)
   BIT_VOID | BIT_OBJECT | BIT_ZERO,   #ifdef ENCODE_DEBUG    /* This argument is only an internal debug helper.    * It's intentionally not part of the function    * prototype, to keep the argument position free for    * other uses in the future. */    BIT_VOID | BIT_INT,   #endif    0);    -  initialize_buf(&data->buf); +  buffer_init(&data->buf);    data->canonic = 0;    data->encoded=allocate_mapping(128);    data->encoded->data->flags |= MAPPING_FLAG_NO_SHRINK;    data->delayed = allocate_array (0);    SET_SVAL(data->counter, T_INT, NUMBER_NUMBER, integer, COUNTER_START);      #ifdef ENCODE_DEBUG    data->debug = args > 2 ? Pike_sp[2-args].u.integer : 0;    data->depth = -2;   #endif
pike.git/src/encode.c:1785:    for (i = 0; i < data->delayed->size; i++)    encode_value2 (ITEM(data->delayed) + i, data, 2);       UNSET_ONERROR(tmp);       if (data->codec) free_object (data->codec);    free_mapping(data->encoded);    free_array (data->delayed);       pop_n_elems(args); -  push_string(low_free_buf(&data->buf)); +  push_string(buffer_finish_pike_string(&data->buf));   }      /*! @decl string encode_value_canonic(mixed value, object|void codec)    *!    *! Code a value into a string on canonical form.    *!    *! Takes a value and converts it to a string on canonical form, much like    *! @[encode_value()]. The canonical form means that if an identical value is    *! encoded, it will produce exactly the same string again, even if it's    *! done at a later time and/or in another Pike process. The produced
pike.git/src/encode.c:1825: Inside #if defined(ENCODE_DEBUG)
   BIT_VOID | BIT_OBJECT | BIT_ZERO,   #ifdef ENCODE_DEBUG    /* This argument is only an internal debug helper.    * It's intentionally not part of the function    * prototype, to keep the argument position free for    * other uses in the future. */    BIT_VOID | BIT_INT,   #endif    0);    -  initialize_buf(&data->buf); +  buffer_init(&data->buf);    data->canonic = 1;    data->encoded=allocate_mapping(128);    data->delayed = allocate_array (0);    SET_SVAL(data->counter, T_INT, NUMBER_NUMBER, integer, COUNTER_START);      #ifdef ENCODE_DEBUG    data->debug = args > 2 ? Pike_sp[2-args].u.integer : 0;    data->depth = -2;   #endif   
pike.git/src/encode.c:1862:    for (i = 0; i < data->delayed->size; i++)    encode_value2 (ITEM(data->delayed) + i, data, 2);       UNSET_ONERROR(tmp);       if (data->codec) free_object (data->codec);    free_mapping(data->encoded);    free_array (data->delayed);       pop_n_elems(args); -  push_string(low_free_buf(&data->buf)); +  push_string(buffer_finish_pike_string(&data->buf));   }         struct unfinished_prog_link   {    struct unfinished_prog_link *next;    struct program *prog;   };      struct unfinished_obj_link