pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:16:   #include "pike_types.h"   #include "fsort.h"   #include "builtin_functions.h"   #include "pike_memory.h"   #include "gc.h"   #include "main.h"   #include "security.h"   #include "stuff.h"   #include "bignum.h"    - RCSID("$Id: array.c,v 1.109 2001/06/08 01:38:09 hubbe Exp $"); + RCSID("$Id: array.c,v 1.110 2001/06/08 10:59:19 hubbe Exp $");      PMOD_EXPORT struct array empty_array=   {    PIKE_CONSTANT_MEMOBJ_INIT(1), /* Never free */    &weak_empty_array, /* Next */    &weak_shrink_empty_array, /* previous (circular) */    0, /* Size = 0 */    0, /* malloced Size = 0 */    0, /* no types */    0, /* no flags */
pike.git/src/array.c:1204:   }      PMOD_EXPORT struct array *add_arrays(struct svalue *argp, INT32 args)   {    INT32 e, size;    struct array *v;       for(size=e=0;e<args;e++)    size+=argp[e].u.array->size;    + #if 1 +  { +  INT32 tmp=0; +  for(e=0;e<args;e++) +  { +  v=argp[e].u.array; +  if(v->refs == 1 && +  (v->item - v->real_item) >= tmp && +  v->malloced_size >= size - tmp) +  { +  debug_malloc_touch(v); +  argp[e].type=T_INT; +  for(tmp=e-1;tmp>=0;tmp--) +  { +  debug_malloc_touch(argp[tmp].u.array); +  v->type_field|=argp[tmp].u.array->type_field; +  assign_svalues_no_free(ITEM(v) - argp[tmp].u.array->size, +  ITEM(argp[tmp].u.array), +  argp[tmp].u.array->size, +  argp[tmp].u.array->type_field); +  v->item-=argp[tmp].u.array->size; +  v->malloced_size+=argp[tmp].u.array->size; +  } +  +  for(tmp=e+1;tmp<args;tmp++) +  { +  debug_malloc_touch(argp[tmp].u.array); +  v->type_field|=argp[tmp].u.array->type_field; +  assign_svalues_no_free(ITEM(v) + v->size, +  ITEM(argp[tmp].u.array), +  argp[tmp].u.array->size, +  argp[tmp].u.array->type_field); +  v->size+=argp[tmp].u.array->size; +  } + #ifdef PIKE_DEBUG +  if(d_flag>1) +  check_array(v); + #endif +  return v; +  } +  tmp+=v->size; +  } +  } + #endif +     if(args && argp[0].u.array->refs==1)    {    e=argp[0].u.array->size;    v=resize_array(argp[0].u.array, size);    argp[0].type=T_INT;    size=e;    e=1;    }else{    v=allocate_array_no_init(size, 0);    v->type_field=0;
pike.git/src/array.c:1974: Inside #if defined(PIKE_DEBUG)
  PMOD_EXPORT void check_array(struct array *a)   {    INT32 e;       if(a->next->prev != a)    fatal("Array check: a->next->prev != a\n");       if(a->size > a->malloced_size)    fatal("Array is larger than malloced block!\n");    +  if(a->size < 0) +  fatal("Array size is negative!\n"); +  +  if(a->malloced_size < 0) +  fatal("Array malloced size is negative!\n"); +  +  if(a->item < a->real_item) +  { + #ifdef DEBUG_MALLOC +  describe(a); + #endif +  fatal("Array item pointer is too small!\n"); +  } +     if(a->refs <=0 )    fatal("Array has zero refs.\n");    -  +     for(e=0;e<a->size;e++)    {    if(! ( (1 << ITEM(a)[e].type) & (a->type_field) ) && ITEM(a)[e].type<16)    fatal("Type field lies.\n");       check_svalue(ITEM(a)+e);    }   }      void check_all_arrays(void)