RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: rpm                              Date:   24-Mar-2009 21:58:28
  Branch: rpm-5_1                          Handle: 2009032420582601

  Modified files:           (Branch: rpm-5_1)
    rpm                     CHANGES
    rpm/lib                 rpmds.h
    rpm/misc                Makefile.am
    rpm/rpmio               rpmhash.c rpmhash.h rpmio.c

  Log:
    - yarn: convert hashTable to usage mutex with refcounts.

  Summary:
    Revision    Changes     Path
    1.2288.2.241+2  -1      rpm/CHANGES
    2.66.2.8    +1  -0      rpm/lib/rpmds.h
    1.32.4.6    +1  -0      rpm/misc/Makefile.am
    1.10.2.1    +56 -49     rpm/rpmio/rpmhash.c
    1.5.2.1     +48 -24     rpm/rpmio/rpmhash.h
    1.127.2.17  +2  -0      rpm/rpmio/rpmio.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2288.2.240 -r1.2288.2.241 CHANGES
  --- rpm/CHANGES       24 Mar 2009 20:13:40 -0000      1.2288.2.240
  +++ rpm/CHANGES       24 Mar 2009 20:58:26 -0000      1.2288.2.241
  @@ -1,5 +1,6 @@
   5.1.7 -> 5.1.8:
  -    - jbj: yarn: convert rpmmg refcount to usage mutex with refcounts.
  +    - jbj: yarn: convert hashTable to usage mutex with refcounts.
  +    - jbj: yarn: convert rpmmg to usage mutex with refcounts.
       - jbj: yarn: convert rpmwf refcount to usage mutex.
       - jbj: rpmdb: don't bother with the silly structure assignment 
initialize.
       - jbj: yarn: wire up rpmdsFini, mark rpmdsFree for destruction.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmds.h
  ============================================================================
  $ cvs diff -u -r2.66.2.7 -r2.66.2.8 rpmds.h
  --- rpm/lib/rpmds.h   20 Mar 2009 19:13:22 -0000      2.66.2.7
  +++ rpm/lib/rpmds.h   24 Mar 2009 20:58:27 -0000      2.66.2.8
  @@ -156,6 +156,7 @@
   /*...@null@*/
   rpmds rpmdsFree(/*...@killref@*/ /*...@only@*/ /*...@null@*/ rpmds ds)
        /*...@modifies ds @*/;
  +
   /** \ingroup rpmds
    * Create and load a dependency set.
    * @param h          header
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/misc/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.32.4.5 -r1.32.4.6 Makefile.am
  --- rpm/misc/Makefile.am      23 Mar 2009 15:29:34 -0000      1.32.4.5
  +++ rpm/misc/Makefile.am      24 Mar 2009 20:58:27 -0000      1.32.4.6
  @@ -36,6 +36,7 @@
        @WITH_XZ_LDFLAGS@ \
        @WITH_LUA_LDFLAGS@ \
        @WITH_FILE_LDFLAGS@ \
  +     @WITH_PCRE_LDFLAGS@ \
        @WITH_XAR_LDFLAGS@
   librpmmisc_la_LIBADD = \
        @ALLOCA@ \
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmhash.c
  ============================================================================
  $ cvs diff -u -r1.10 -r1.10.2.1 rpmhash.c
  --- rpm/rpmio/rpmhash.c       8 Feb 2008 17:42:48 -0000       1.10
  +++ rpm/rpmio/rpmhash.c       24 Mar 2009 20:58:27 -0000      1.10.2.1
  @@ -4,9 +4,12 @@
    */
   
   #include "system.h"
  +#include <rpmio.h>
   #include <rpmhash.h>
   #include "debug.h"
   
  +int _ht_debug = 0;
  +
   typedef /*...@owned@*/ const void * voidptr;
   
   typedef      struct hashBucket_s * hashBucket;
  @@ -23,6 +26,7 @@
   /**
    */
   struct hashTable_s {
  +    struct rpmioItem_s _item;        /*!< usage mutex and pool identifier. */
       int numBuckets;                  /*!< number of hash buckets */
       size_t keySize;                  /*!< size of key (0 if unknown) */
       int freeData;    /*!< should data be freed when table is destroyed? */
  @@ -32,18 +36,6 @@
   };
   
   /**
  - * Wrapper to free(3), hides const compilation noise, permit NULL, return 
NULL.
  - * @param p          memory to free
  - * @retval           NULL always
  - */
  -/*...@unused@*/ static inline /*...@null@*/ void *
  -_free(/*...@only@*/ /*...@null@*/ const void * p) /*...@modifies p...@*/
  -{
  -    if (p != NULL)   free((void *)p);
  -    return NULL;
  -}
  -
  -/**
    * Find entry in hash table.
    * @param ht            pointer to hash table
    * @param key           pointer to key value
  @@ -141,24 +133,6 @@
       return h;
   }
   
  -hashTable htCreate(int numBuckets, size_t keySize, int freeData,
  -             hashFunctionType fn, hashEqualityType eq)
  -{
  -    hashTable ht;
  -
  -    ht = xmalloc(sizeof(*ht));
  -    ht->numBuckets = numBuckets;
  -    ht->buckets = xcalloc(numBuckets, sizeof(*ht->buckets));
  -    ht->keySize = keySize;
  -    ht->freeData = freeData;
  -    /*...@-assignexpose@*/
  -    ht->fn = (fn != NULL ? fn : hashFunctionString);
  -    ht->eq = (eq != NULL ? eq : hashEqualityString);
  -    /*...@=assignexpose@*/
  -
  -    return ht;
  -}
  -
   void htAddEntry(hashTable ht, const void * key, const void * data)
   {
       uint32_t hash = 0;
  @@ -189,8 +163,35 @@
       b->data[b->dataCount++] = data;
   }
   
  -hashTable htFree(hashTable ht)
  +int htHasEntry(hashTable ht, const void * key)
  +{
  +    hashBucket b;
  +
  +    if (!(b = findEntry(ht, key))) return 0; else return 1;
  +}
  +
  +int htGetEntry(hashTable ht, const void * key, const void * data,
  +            int * dataCount, const void * tableKey)
  +{
  +    hashBucket b;
  +
  +    if ((b = findEntry(ht, key)) == NULL)
  +     return 1;
  +
  +    if (data)
  +     *(const void ***)data = (const void **) b->data;
  +    if (dataCount)
  +     *dataCount = b->dataCount;
  +    if (tableKey)
  +     *(const void **)tableKey = b->key;
  +
  +    return 0;
  +}
  +
  +static void htFini(void * _ht)
  +     /*...@modifies *_ht @*/
   {
  +    hashTable ht = _ht;
       hashBucket b, n;
       int i;
   
  @@ -213,31 +214,37 @@
       }
   
       ht->buckets = _free(ht->buckets);
  -    ht = _free(ht);
  -    return NULL;
   }
   
  -int htHasEntry(hashTable ht, const void * key)
  +/*...@unchecked@*/ /*...@null@*/
  +rpmioPool _htPool;
  +
  +static hashTable htGetPool(/*...@null@*/ rpmioPool pool)
  +     /*...@modifies pool @*/
   {
  -    hashBucket b;
  +    hashTable ht;
   
  -    if (!(b = findEntry(ht, key))) return 0; else return 1;
  +    if (_htPool == NULL) {
  +     _htPool = rpmioNewPool("ht", sizeof(*ht), -1, _ht_debug,
  +                     NULL, NULL, htFini);
  +     pool = _htPool;
  +    }
  +    return (hashTable) rpmioGetPool(pool, sizeof(*ht));
   }
   
  -int htGetEntry(hashTable ht, const void * key, const void * data,
  -            int * dataCount, const void * tableKey)
  +hashTable htCreate(int numBuckets, size_t keySize, int freeData,
  +             hashFunctionType fn, hashEqualityType eq)
   {
  -    hashBucket b;
  +    hashTable ht = htGetPool(_htPool);
   
  -    if ((b = findEntry(ht, key)) == NULL)
  -     return 1;
  -
  -    if (data)
  -     *(const void ***)data = (const void **) b->data;
  -    if (dataCount)
  -     *dataCount = b->dataCount;
  -    if (tableKey)
  -     *(const void **)tableKey = b->key;
  +    ht->numBuckets = numBuckets;
  +    ht->buckets = xcalloc(numBuckets, sizeof(*ht->buckets));
  +    ht->keySize = keySize;
  +    ht->freeData = freeData;
  +    /*...@-assignexpose@*/
  +    ht->fn = (fn != NULL ? fn : hashFunctionString);
  +    ht->eq = (eq != NULL ? eq : hashEqualityString);
  +    /*...@=assignexpose@*/
   
  -    return 0;
  +    return htLink(ht);
   }
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmhash.h
  ============================================================================
  $ cvs diff -u -r1.5 -r1.5.2.1 rpmhash.h
  --- rpm/rpmio/rpmhash.h       8 Feb 2008 17:42:48 -0000       1.5
  +++ rpm/rpmio/rpmhash.h       24 Mar 2009 20:58:27 -0000      1.5.2.1
  @@ -53,30 +53,6 @@
        /*...@*/;
   
   /**
  - * Create hash table.
  - * If keySize > 0, the key is duplicated within the table (which costs
  - * memory, but may be useful anyway.
  - * @param numBuckets    number of hash buckets
  - * @param keySize       size of key (0 if unknown)
  - * @param freeData      Should data be freed when table is destroyed?
  - * @param fn            function to generate hash key (NULL for default)
  - * @param eq            function to compare keys for equality (NULL for 
default)
  - * @return           pointer to initialized hash table
  - */
  -hashTable htCreate(int numBuckets, size_t keySize, int freeData,
  -             /*...@null@*/ hashFunctionType fn, /*...@null@*/ 
hashEqualityType eq)
  -     /*...@*/; 
  -
  -/**
  - * Destroy hash table.
  - * @param ht            pointer to hash table
  - * @return           NULL always
  - */
  -/*...@null@*/
  -hashTable htFree( /*...@only@*/ hashTable ht)
  -     /*...@modifies ht @*/;
  -
  -/**
    * Add item to hash table.
    * @param ht            pointer to hash table
    * @param key           pointer to key
  @@ -111,6 +87,54 @@
   int htHasEntry(hashTable ht, const void * key)
        /*...@*/;
   
  +/**
  + * Unreference a hash table instance.
  + * @param ht         hash table
  + * @return           NULL if free'd
  + */
  +/*...@unused@*/ /*...@null@*/
  +hashTable htUnlink (/*...@killref@*/ /*...@only@*/ /*...@null@*/ hashTable 
ht);
  +     /*...@modifies ht @*/;
  +#define      htUnlink(_ht)   \
  +    ((hashTable)rpmioUnlinkPoolItem((rpmioItem)(_ht), __FUNCTION__, 
__FILE__, __LINE__))
  +
  +/**
  + * Reference a hash table instance.
  + * @param ds         hash table
  + * @return           new hash table reference
  + */
  +/*...@unused@*/ /*...@newref@*/ /*...@null@*/
  +hashTable htLink (/*...@null@*/ hashTable ht)
  +     /*...@modifies ht @*/;
  +#define      htLink(_ht)     \
  +    ((hashTable)rpmioLinkPoolItem((rpmioItem)(_ht), __FUNCTION__, __FILE__, 
__LINE__))
  +
  +/**
  + * Destroy hash table.
  + * @param ht            pointer to hash table
  + * @return           NULL always
  + */
  +/*...@null@*/
  +hashTable htFree( /*...@only@*/ hashTable ht)
  +     /*...@modifies ht @*/;
  +#define      htFree(_ht)     \
  +    ((hashTable)rpmioFreePoolItem((rpmioItem)(_ht), __FUNCTION__, __FILE__, 
__LINE__))
  +
  +/**
  + * Create hash table.
  + * If keySize > 0, the key is duplicated within the table (which costs
  + * memory, but may be useful anyway.
  + * @param numBuckets    number of hash buckets
  + * @param keySize       size of key (0 if unknown)
  + * @param freeData      Should data be freed when table is destroyed?
  + * @param fn            function to generate hash key (NULL for default)
  + * @param eq            function to compare keys for equality (NULL for 
default)
  + * @return           pointer to initialized hash table
  + */
  +hashTable htCreate(int numBuckets, size_t keySize, int freeData,
  +             /*...@null@*/ hashFunctionType fn, /*...@null@*/ 
hashEqualityType eq)
  +     /*...@*/; 
  +
   #ifdef __cplusplus
   }
   #endif
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmio.c
  ============================================================================
  $ cvs diff -u -r1.127.2.16 -r1.127.2.17 rpmio.c
  --- rpm/rpmio/rpmio.c 24 Mar 2009 20:13:40 -0000      1.127.2.16
  +++ rpm/rpmio/rpmio.c 24 Mar 2009 20:58:27 -0000      1.127.2.17
  @@ -3155,6 +3155,7 @@
       extern rpmioPool _xarPool;
       extern rpmioPool _urlPool;
       extern rpmioPool _rpmmgPool;
  +    extern rpmioPool _htPool;
   
   #if defined(WITH_LUA)
       (void) rpmluaFree(NULL);
  @@ -3170,6 +3171,7 @@
   #endif
       urlFreeCache();
   
  +    _htPool = rpmioFreePool(_htPool);
       _rpmmgPool = rpmioFreePool(_rpmmgPool);
       _digPool = rpmioFreePool(_digPool);
       _xarPool = rpmioFreePool(_xarPool);
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to