pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:662:   PMOD_EXPORT struct pike_string *debug_begin_shared_string(size_t len)   {    struct pike_string *t;   #ifdef PIKE_DEBUG    extern int d_flag;    if(d_flag>10)    verify_shared_strings_tables();   #endif    if (len <= SHORT_STRING_THRESHOLD)    { -  t=(struct pike_string *)ba_alloc(&string_allocator); +  t=ba_alloc(&string_allocator);    t->flags = STRING_NOT_HASHED | STRING_NOT_SHARED | STRING_IS_SHORT;    } else    { -  t=(struct pike_string *)xalloc(len + 1 + sizeof(struct pike_string_hdr)); +  t=xalloc(len + 1 + sizeof(struct pike_string_hdr));    t->flags = STRING_NOT_HASHED | STRING_NOT_SHARED;    }   #ifdef ATOMIC_SVALUE    t->ref_type = T_STRING;   #endif    t->refs = 0;    add_ref(t); /* For DMALLOC */    t->str[len]=0;    t->len=len;   /* t->min = t->max = 0; */
pike.git/src/stralloc.c:799: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    extern int d_flag;    if(d_flag>10)    verify_shared_strings_tables();   #endif    if ((len<<shift) <= SHORT_STRING_THRESHOLD) {   #ifdef PIKE_DEBUG    if (shift > 2)    Pike_fatal("Unsupported string shift: %d\n", shift);   #endif /* PIKE_DEBUG */ -  t=(struct pike_string *)ba_alloc(&string_allocator); +  t=ba_alloc(&string_allocator);    t->flags = STRING_NOT_HASHED|STRING_NOT_SHARED|STRING_IS_SHORT;    } else { -  t=(struct pike_string *)xalloc(((len + 1)<<shift) + -  sizeof(struct pike_string_hdr)); +  t=xalloc(((len + 1)<<shift) + sizeof(struct pike_string_hdr));    t->flags = STRING_NOT_HASHED|STRING_NOT_SHARED;    }   #ifdef ATOMIC_SVALUE    t->ref_type = T_STRING;   #endif    t->refs = 0;    add_ref(t); /* For DMALLOC */    t->len=len;    t->size_shift=shift;    DO_IF_DEBUG(t->next = NULL);
pike.git/src/stralloc.c:1726:       if (a->flags & STRING_IS_SHORT )    {    if (size <= SHORT_STRING_THRESHOLD/(1<<a->size_shift)) {    /* There's already space enough. */    a->len = size;    low_set_index(a, size, 0);    return a;    }    } else { -  r=(struct pike_string *)realloc((char *)a, -  sizeof(struct pike_string_hdr)+ -  ((size+1)<<a->size_shift)); +  r=realloc(a, sizeof(struct pike_string_hdr)+((size+1)<<a->size_shift));    }       if(!r)    {    r=begin_wide_shared_string(size, a->size_shift);    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);
pike.git/src/stralloc.c:2222:   /*** init/exit memory ***/   void init_shared_string_table(void)   {    for(hashprimes_entry=0;hashprimes[hashprimes_entry]<BEGIN_HASH_SIZE;hashprimes_entry++);    SET_HSIZE(hashprimes_entry);    base_table=xcalloc(sizeof(struct pike_string *), htable_size);      #ifdef PIKE_RUN_UNLOCKED    {    int h; -  bucket_locks=(PIKE_MUTEX_T *)xalloc(sizeof(PIKE_MUTEX_T)*BUCKET_LOCKS); +  bucket_locks=xalloc(sizeof(PIKE_MUTEX_T)*BUCKET_LOCKS);    for(h=0;h<BUCKET_LOCKS;h++) mt_init(bucket_locks + h);    }   #endif    empty_pike_string = make_shared_string("");    empty_pike_string->flags |= STRING_CONTENT_CHECKED | STRING_IS_LOWERCASE | STRING_IS_UPPERCASE;    empty_pike_string->min = empty_pike_string->max = 0;   }      #ifdef DO_PIKE_CLEANUP   PMOD_EXPORT struct shared_string_location *all_shared_string_locations;