pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:1637:       switch (string_is_short(a) | ((nbytes <= sizeof(struct pike_string)) << 1)) {    case 0:    s=realloc(a->str, nbytes);    if (!s)    Pike_error("Out of memory in realloc_unlinked_string. Could not allocate %"PRINTSIZET" bytes.\n",    nbytes);    break;    case 1: { // old string was short    size_t obytes = (size_t)(a->len+1) << a->size_shift; -  a->flags &= ~STRING_IS_SHORT; +     s = xalloc(nbytes); -  +  a->flags &= ~STRING_IS_SHORT;    memcpy(s, a->str, obytes);    ba_free(&string_allocator, a->str);    break;    }    case 2: // new string is short -  a->flags |= STRING_IS_SHORT; +     s = ba_alloc(&string_allocator); -  +  a->flags |= STRING_IS_SHORT;    memcpy(s, a->str, nbytes);    free(a->str);    break;    case 3: // both are short    goto done;    }       a->str = s;   done:    a->len=size;