pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:3230:    else if(!(a = OBJ2_BUFFER(Pike_sp[j-args].u.object)->str.s))    continue;    sum += a->len;    shift |= a->size_shift;    }       s = str->str.s;    sum += pos;    shift |= str->str.known_shift;    shift = shift & ~(shift >> 1); -  if (sum > s->len) -  string_build_mkspace(&str->str, sum - s->len, shift); +  j = sum - s->len; +  if (j>0) { +  if (str->initial > sum) +  j = str->initial-s->len; +  string_build_mkspace(&str->str, j, shift); +  }    else if (shift != str->str.known_shift)    string_build_mkspace(&str->str, 0, shift);    s = str->str.s;    /* We know it will be a string that really is this wide. */    str->str.known_shift = shift;       if (s->len < pos) // Clear the padding    MEMSET(s->str + (s->len << s->size_shift),    0, (pos - s->len) << s->size_shift);   
pike.git/src/builtin.cmod:3353:    *! @seealso    *! @[get_copy()], @[clear()]    */    PIKEFUN string get( )    {    struct Buffer_struct *str = THIS;    struct pike_string *s = finish_string_builder( &str->str );    if( Pike_fp->current_object->flags & OBJECT_CLEAR_ON_EXIT )    s->flags |= STRING_CLEAR_ON_EXIT;    push_string(s); -  init_string_builder_alloc(&str->str, str->initial, 0); +  // Pick a smaller size to minimise fragmentation +  // addat() will expand if it notices reuse of +  // the Buffer +  init_string_builder_alloc(&str->str, sizeof(struct svalue), 0);    }       /*! @decl Buffer|void cut(int index, int|void end_or_none,void|int discard)    *!    *! Cut and delete the range of data from the current buffer.    *! Returns a new buffer with the cut data, unless discard is true.    *!    *! @seealso    *! @[get()], @[get_copy()], @[clear()]    */