Jabberd14-1.6.0/jabberd/lib/xhash.c/xhash_new

Last-modified: 2007-03-05 (月) 18:30:37

このページを編集する際は,編集に関する方針に従ってください.

概要

  • xht xhash_new(int prime)

引数

 * @param prime size of the hash (use a prime number!)
 * @return pointer to the new hash

実装

xht xhash_new(int prime) {
    xht xnew;
    pool p;
/*    log_debug(ZONE,"creating new hash table of size %d",prime); */
  • sizeof(_xhn)*prime(チェインハッシュのチェインの数)と sizeof(_xht)(チェインハッシュのルート)分のヒープを確保
        p = pool_heap(sizeof(_xhn)*prime + sizeof(_xht));
  • ルートの割り当て
        xnew = pmalloco(p, sizeof(_xht));
        xnew->prime = prime;
        xnew->p = p;
  • チェインの割り当て
        xnew->zen = pmalloco(p, sizeof(xhn)*prime); /* array of xhn size of prime */
        pool_cleanup(p, _xhash_cleaner, (void*)xnew);
        return xnew;
    }

呼出元

#related: relatedプラグインは廃止されました。