Exemple #1
0
/*
** Re-hash
*/
static void rehash (Hash *t)
{
 int i;
 int   nold = nhash(t);
 Node *vold = nodevector(t);
 nhash(t) = luaI_redimension(nhash(t));
 nodevector(t) = hashnodecreate(nhash(t));
 for (i=0; i<nold; i++)
 {
  Node *n = vold+i;
  if (tag(ref(n)) != LUA_T_NIL && tag(val(n)) != LUA_T_NIL)
   *node(t, present(t, ref(n))) = *n;  /* copy old node to new hahs */
 }
 luaI_free(vold);
}
Exemple #2
0
static void rehash(Hash *t) {
	int32 nold = nhash(t);
	Node *vold = nodevector(t);
	int32 i;
	if (!emptyslots(t))
		nhash(t) = luaO_redimension(nhash(t));
	nodevector(t) = hashnodecreate(nhash(t));
	for (i = 0; i < nold; i++) {
		Node *n = vold + i;
		if (ttype(ref(n)) != LUA_T_NIL && ttype(val(n)) != LUA_T_NIL)
			*node(t, present(t, ref(n))) = *n;  // copy old node to luaM_new hash
	}
	nblocks += gcsize(t->nhash) - gcsize(nold);
	luaM_free(vold);
}
Exemple #3
0
static void rehash (Hash *t)
{
  int nold = nhash(t);
  Node *vold = nodevector(t);
  int nnew = newsize(t);
  int i;
  nodevector(t) = hashnodecreate(nnew);
  nhash(t) = nnew;
  for (i=0; i<nold; i++) {
    Node *n = vold+i;
    if (ttype(ref(n)) != LUA_T_NIL && ttype(val(n)) != LUA_T_NIL)
      *node(t, present(t, ref(n))) = *n;  /* copy old node to luaM_new hash */
  }
  L->nblocks += gcsize(nnew)-gcsize(nold);
  luaM_free(vold);
}
Exemple #4
0
/*
** Create a new hash. Return the hash pointer or NULL on error.
*/
static Hash *hashcreate (int nhash)
{
 Hash *t = new(Hash);
 nhash = luaI_redimension((int)((float)nhash/REHASH_LIMIT));
 nodevector(t) = hashnodecreate(nhash);
 nhash(t) = nhash;
 nuse(t) = 0;
 markarray(t) = 0;
 return t;
}
Exemple #5
0
Hash *luaH_new(int32 nhash) {
	Hash *t = luaM_new(Hash);
	nhash = luaO_redimension((int32)((float)nhash / REHASH_LIMIT));
	nodevector(t) = hashnodecreate(nhash);
	nhash(t) = nhash;
	nuse(t) = 0;
	t->htag = TagDefault;
	luaO_insertlist(&roottable, (GCnode *)t);
	nblocks += gcsize(nhash);
	return t;
}
Exemple #6
0
/*
** Delete a hash
*/
static void hashdelete (Hash *t)
{
 luaI_free (nodevector(t));
 luaI_free(t);
}