pike.git / src / mapping.c

version» Context lines:

pike.git/src/mapping.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: mapping.c,v 1.10 1997/01/27 01:21:34 hubbe Exp $"); + RCSID("$Id: mapping.c,v 1.11 1997/01/29 21:43:07 hubbe Exp $");   #include "main.h"   #include "types.h"   #include "object.h"   #include "mapping.h"   #include "svalue.h"   #include "array.h"   #include "macros.h"   #include "language.h"   #include "error.h"   #include "memory.h"
pike.git/src/mapping.c:70:    */   static void init_mapping(struct mapping *m, INT32 size)   {    char *tmp;    INT32 e;    INT32 hashsize,hashspace;      #ifdef DEBUG    if(size < 0) fatal("init_mapping with negative value.\n");   #endif +  if(size<3) size=3;       hashsize=size / AVG_LINK_LENGTH + 1;    if(!(hashsize & 1)) hashsize++;    hashspace=hashsize+1;    e=sizeof(struct keypair)*size+ sizeof(struct keypair *)*hashspace;    tmp=(char *)xalloc(e);       m->hash=(struct keypair **) tmp;    m->hashsize=hashsize;       tmp+=sizeof(struct keypair *)*hashspace; -  m->free_list=(struct keypair *) tmp; +        MEMSET((char *)m->hash, 0, sizeof(struct keypair *) * m->hashsize);    -  +  m->free_list=(struct keypair *) tmp;    for(e=1;e<size;e++)    m->free_list[e-1].next = m->free_list + e;    m->free_list[e-1].next=0;       m->ind_types = 0;    m->val_types = 0;    m->size = 0;   }      /* This function allocates an empty mapping with room for 'size' values