pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:18:      #include <errno.h>   #include <float.h>   #include <ctype.h>   #include <math.h>      #ifndef HUGE   #define HUGE HUGE_VAL   #endif /*!HUGE*/    - RCSID("$Id: stralloc.c,v 1.93 2000/08/10 17:57:04 grubba Exp $"); + RCSID("$Id: stralloc.c,v 1.94 2000/08/10 18:00:09 grubba Exp $");      #define BEGIN_HASH_SIZE 997   #define MAX_AVG_LINK_LENGTH 3      /* Experimental dynamic hash length */   #ifndef HASH_PREFIX   static unsigned int HASH_PREFIX=64;   static unsigned int need_more_hash_prefix=0;   #endif   
pike.git/src/stralloc.c:1587:   }      PMOD_EXPORT void init_string_builder(struct string_builder *s, int mag)   {    s->malloced=256;    s->s=begin_wide_shared_string(256,mag);    s->s->len=0;    s->known_shift=0;   }    - static void string_build_mkspace(struct string_builder *s, int chars, int mag) + static void string_build_mkspace(struct string_builder *s, +  ptrdiff_t chars, int mag)   {    if(mag > s->s->size_shift)    {    struct pike_string *n; -  int l=s->s->len+chars+s->malloced; +  ptrdiff_t l = s->s->len + chars + s->malloced;    n=begin_wide_shared_string(l,mag);    pike_string_cpy(MKPCHARP_STR(n),s->s);    n->len=s->s->len;    s->malloced=l;    free((char *)s->s);    s->s=n;    }    else if(s->s->len+chars > s->malloced)    { -  int newlen=MAXIMUM(s->malloced*2,s->s->len+chars); +  ptrdiff_t newlen = MAXIMUM(s->malloced*2, s->s->len + chars);       s->s=(struct pike_string *)realloc((char *)s->s,    sizeof(struct pike_string)+    ((newlen+1)<<s->s->size_shift));    if(!s->s)    fatal("Out of memory.\n");    s->malloced=newlen;    }   }    - PMOD_EXPORT void *string_builder_allocate(struct string_builder *s, int chars, int mag) + PMOD_EXPORT void *string_builder_allocate(struct string_builder *s, ptrdiff_t chars, int mag)   {    void *ret; -  string_build_mkspace(s,chars,mag); +  string_build_mkspace(s, chars, mag);    if(chars<0) s->known_shift=0; -  ret=s->s->str + (s->s->len<<s->s->size_shift); -  s->s->len+=chars; +  ret = s->s->str + (s->s->len<<s->s->size_shift); +  s->s->len += chars;    return ret;   }      PMOD_EXPORT void string_builder_putchar(struct string_builder *s, int ch)   {    INT32 i;    string_build_mkspace(s,1,min_magnitude(ch));    s->known_shift=MAXIMUM(min_magnitude(ch),s->known_shift);    i=s->s->len++;    low_set_index(s->s,i,ch);