pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:2183:    Pike_sp += a->size;    a->size=0;    free_array(a);    }else{    assign_svalues_no_free(Pike_sp, ITEM(a), a->size, a->type_field);    Pike_sp += a->size;    free_array(a);    }   }    - void describe_array_low(struct array *a, struct processing *p, int indent) + void describe_array_low(struct byte_buffer *buf, struct array *a, struct processing *p, int indent)   {    INT32 e,d;    indent += 2;       for(e=0; e<a->size; e++)    { -  if(e) my_strcat(",\n"); -  for(d=0; d<indent; d++) my_putchar(' '); -  describe_svalue(ITEM(a)+e,indent,p); +  buffer_ensure_space(buf, indent + 2); +  if(e) buffer_add_str_unsafe(buf, ",\n"); +  for(d=0; d<indent; d++) buffer_add_char_unsafe(buf, ' '); +  describe_svalue(buf, ITEM(a)+e,indent,p);    }   }         #ifdef PIKE_DEBUG   void simple_describe_array(struct array *a)   { -  dynamic_buffer save_buf; +     char *s;    if (a->size) { -  init_buf(&save_buf); -  describe_array_low(a,0,0); -  s=simple_free_buf(&save_buf); -  fprintf(stderr,"({\n%s\n})\n",s); -  free(s); +  byte_buffer buf = BUFFER_INIT(); +  describe_array_low(buf,a,0,0); +  fprintf(stderr,"({\n%s\n})\n",buffer_get_string(&buf)); +  buffer_free(&buf);    }    else    fputs ("({ })\n", stderr);   } -  - void describe_index(struct array *a, -  int e, -  struct processing *p, -  int indent) - { -  describe_svalue(ITEM(a)+e, indent, p); - } +    #endif       - void describe_array(struct array *a,struct processing *p,int indent) + void describe_array(struct byte_buffer *buffer,struct array *a,struct processing *p,int indent)   {    struct processing doing;    INT32 e;    char buf[60];    if(! a->size)    { -  my_strcat("({ })"); +  buffer_add_str(buffer, "({ })");    return;    }       doing.next=p;    doing.pointer_a=(void *)a;    for(e=0;p;e++,p=p->next)    {    if(p->pointer_a == (void *)a)    {    sprintf(buf,"@%ld",(long)e); -  my_strcat(buf); +  buffer_add_str(buffer, buf);    return;    }    }       if (a->size == 1) {    sprintf(buf, "({ /* 1 element */\n");    } else {    sprintf(buf, "({ /* %ld elements */\n", (long)a->size);    } -  my_strcat(buf); -  describe_array_low(a,&doing,indent); -  my_putchar('\n'); -  for(e=2; e<indent; e++) my_putchar(' '); -  my_strcat("})"); +  buffer_add_str(buffer, buf); +  describe_array_low(buffer,a,&doing,indent); +  buffer_add_char(buffer, '\n'); +  for(e=2; e<indent; e++) buffer_add_char(buffer, ' '); +  buffer_add_str(buffer, "})");   }      /**    * Pops a number of arguments off of the stack an puts them in an array.    * The 'top' of the stack will be the last element in the array.    * @param args The number of arguments to aggregate.    */   PMOD_EXPORT struct array *aggregate_array(INT32 args)   {    struct array *a;