pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:1771:    }    } else {    r=(struct pike_string *)realloc((char *)a,    sizeof(struct pike_string_hdr)+    ((size+1)<<a->size_shift));    }       if(!r)    {    r=begin_wide_shared_string(size, a->size_shift); -  /* we keep both content information and the clear flags */ -  r->flags |= a->flags & (STRING_CONTENT_MASK|STRING_CLEAR_ON_EXIT); +  r->flags |= a->flags & ~15;    r->min = a->min;    r->max = a->max;    if (a->len <= size) {    MEMCPY(r->str, a->str, a->len<<a->size_shift);    } else {    MEMCPY(r->str, a->str, size<<a->size_shift);    }    free_string(a);    }   
pike.git/src/stralloc.c:1800:    ptrdiff_t size)   {    struct pike_string *r;    if(a->refs==1)    {    unlink_pike_string(a);    return realloc_unlinked_string(a, size);    }else{    r=begin_wide_shared_string(size,a->size_shift);    MEMCPY(r->str, a->str, a->len<<a->size_shift); -  /* we keep both content information and the clear flags */ -  r->flags |= a->flags & (STRING_CONTENT_MASK|STRING_CLEAR_ON_EXIT); +  r->flags |= a->flags & ~15;    r->min = a->min;    r->max = a->max;    free_string(a);    return r;    }   }      struct pike_string *new_realloc_shared_string(struct pike_string *a, INT32 size, int shift)   {    struct pike_string *r;    if(shift == a->size_shift) return realloc_shared_string(a,size);       r=begin_wide_shared_string(size,shift);    pike_string_cpy(MKPCHARP_STR(r),a); -  r->flags |= (a->flags & (STRING_CONTENT_MASK|STRING_CLEAR_ON_EXIT)); +  r->flags |= (a->flags & ~15);    r->min = a->min;    r->max = a->max;    free_string(a);    return r;   }         /* Modify one index in a shared string    * Not suitable for building new strings or changing multiple characters    * within a string!
pike.git/src/stralloc.c:1989:    }   }      PMOD_EXPORT void set_flags_for_add( struct pike_string *ret,    unsigned char aflags,    unsigned char amin,    unsigned char amax,    struct pike_string *b)   {    if( !b->len ) { -  ret->flags |= aflags & (STRING_CONTENT_MASK|STRING_CLEAR_ON_EXIT); +  ret->flags |= aflags & ~15;    ret->min = amin;    ret->max = amax;    return;    }    if( aflags & b->flags & STRING_CONTENT_CHECKED )    {    ret->min = MINIMUM( amin, b->min );    ret->max = MAXIMUM( amax, b->max );    ret->flags |= STRING_CONTENT_CHECKED;    }    else    ret->flags &= ~STRING_CONTENT_CHECKED;       ret->flags &= ~(STRING_IS_LOWERCASE | STRING_IS_UPPERCASE);    ret->flags |= (aflags & b->flags & (STRING_IS_LOWERCASE | STRING_IS_UPPERCASE)); -  ret->flags |= (aflags | b->flags) & STRING_CLEAR_ON_EXIT; +    }      PMOD_EXPORT void update_flags_for_add( struct pike_string *a, struct pike_string *b)   {    if( !b->len ) return;    if( a->flags & STRING_CONTENT_CHECKED )    {    if(b->flags & STRING_CONTENT_CHECKED)    {    if( b->min < a->min ) a->min = b->min;    if( b->max > a->max ) a->max = b->max;    }    else    a->flags &= ~STRING_CONTENT_CHECKED;    }       a->flags &= ~(STRING_IS_LOWERCASE | STRING_IS_UPPERCASE) | b->flags; -  a->flags |= b->flags & STRING_CLEAR_ON_EXIT; +    }      /*** Add strings ***/   PMOD_EXPORT struct pike_string *add_shared_strings(struct pike_string *a,    struct pike_string *b)   {    struct pike_string *ret;    PCHARP tmp;    int target_size=MAXIMUM(a->size_shift,b->size_shift);