Diff for /embedaddon/libxml2/hash.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2013/07/22 01:22:18 version 1.1.1.3, 2014/06/15 19:53:31
Line 83  xmlHashComputeKey(xmlHashTablePtr table, const xmlChar Line 83  xmlHashComputeKey(xmlHashTablePtr table, const xmlChar
                   const xmlChar *name2, const xmlChar *name3) {                    const xmlChar *name2, const xmlChar *name3) {
     unsigned long value = 0L;      unsigned long value = 0L;
     char ch;      char ch;
    
 #ifdef HASH_RANDOMIZATION  #ifdef HASH_RANDOMIZATION
     value = table->random_seed;      value = table->random_seed;
 #endif  #endif
Line 93  xmlHashComputeKey(xmlHashTablePtr table, const xmlChar Line 93  xmlHashComputeKey(xmlHashTablePtr table, const xmlChar
             value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);              value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
         }          }
     }      }
       value = value ^ ((value << 5) + (value >> 3));
     if (name2 != NULL) {      if (name2 != NULL) {
         while ((ch = *name2++) != 0) {          while ((ch = *name2++) != 0) {
             value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);              value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
         }          }
     }      }
       value = value ^ ((value << 5) + (value >> 3));
     if (name3 != NULL) {      if (name3 != NULL) {
         while ((ch = *name3++) != 0) {          while ((ch = *name3++) != 0) {
             value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);              value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
Line 113  xmlHashComputeQKey(xmlHashTablePtr table, Line 115  xmlHashComputeQKey(xmlHashTablePtr table,
                    const xmlChar *prefix3, const xmlChar *name3) {                     const xmlChar *prefix3, const xmlChar *name3) {
     unsigned long value = 0L;      unsigned long value = 0L;
     char ch;      char ch;
    
 #ifdef HASH_RANDOMIZATION  #ifdef HASH_RANDOMIZATION
     value = table->random_seed;      value = table->random_seed;
 #endif  #endif
Line 133  xmlHashComputeQKey(xmlHashTablePtr table, Line 135  xmlHashComputeQKey(xmlHashTablePtr table,
             value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);              value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
         }          }
     }      }
       value = value ^ ((value << 5) + (value >> 3));
     if (prefix2 != NULL) {      if (prefix2 != NULL) {
         while ((ch = *prefix2++) != 0) {          while ((ch = *prefix2++) != 0) {
             value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);              value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
Line 144  xmlHashComputeQKey(xmlHashTablePtr table, Line 147  xmlHashComputeQKey(xmlHashTablePtr table,
             value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);              value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
         }          }
     }      }
       value = value ^ ((value << 5) + (value >> 3));
     if (prefix3 != NULL) {      if (prefix3 != NULL) {
         while ((ch = *prefix3++) != 0) {          while ((ch = *prefix3++) != 0) {
             value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);              value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
Line 169  xmlHashComputeQKey(xmlHashTablePtr table, Line 173  xmlHashComputeQKey(xmlHashTablePtr table,
 xmlHashTablePtr  xmlHashTablePtr
 xmlHashCreate(int size) {  xmlHashCreate(int size) {
     xmlHashTablePtr table;      xmlHashTablePtr table;
  
     if (size <= 0)      if (size <= 0)
         size = 256;          size = 256;
  
     table = xmlMalloc(sizeof(xmlHashTable));      table = xmlMalloc(sizeof(xmlHashTable));
     if (table) {      if (table) {
         table->dict = NULL;          table->dict = NULL;
Line 180  xmlHashCreate(int size) { Line 184  xmlHashCreate(int size) {
         table->nbElems = 0;          table->nbElems = 0;
         table->table = xmlMalloc(size * sizeof(xmlHashEntry));          table->table = xmlMalloc(size * sizeof(xmlHashEntry));
         if (table->table) {          if (table->table) {
            memset(table->table, 0, size * sizeof(xmlHashEntry));            memset(table->table, 0, size * sizeof(xmlHashEntry));
 #ifdef HASH_RANDOMIZATION  #ifdef HASH_RANDOMIZATION
             table->random_seed = __xmlRandom();              table->random_seed = __xmlRandom();
 #endif  #endif
            return(table);            return(table);
         }          }
         xmlFree(table);          xmlFree(table);
     }      }
Line 230  xmlHashGrow(xmlHashTablePtr table, int size) { Line 234  xmlHashGrow(xmlHashTablePtr table, int size) {
 #ifdef DEBUG_GROW  #ifdef DEBUG_GROW
     unsigned long nbElem = 0;      unsigned long nbElem = 0;
 #endif  #endif
  
     if (table == NULL)      if (table == NULL)
         return(-1);          return(-1);
     if (size < 8)      if (size < 8)
Line 242  xmlHashGrow(xmlHashTablePtr table, int size) { Line 246  xmlHashGrow(xmlHashTablePtr table, int size) {
     oldtable = table->table;      oldtable = table->table;
     if (oldtable == NULL)      if (oldtable == NULL)
         return(-1);          return(-1);
  
     table->table = xmlMalloc(size * sizeof(xmlHashEntry));      table->table = xmlMalloc(size * sizeof(xmlHashEntry));
     if (table->table == NULL) {      if (table->table == NULL) {
         table->table = oldtable;          table->table = oldtable;
Line 252  xmlHashGrow(xmlHashTablePtr table, int size) { Line 256  xmlHashGrow(xmlHashTablePtr table, int size) {
     table->size = size;      table->size = size;
   
     /*  If the two loops are merged, there would be situations where      /*  If the two loops are merged, there would be situations where
        a new entry needs to allocated and data copied into it from         a new entry needs to allocated and data copied into it from
         the main table. So instead, we run through the array twice, first          the main table. So instead, we run through the array twice, first
         copying all the elements in the main array (where we can't get          copying all the elements in the main array (where we can't get
         conflicts) and then the rest, so we only free (and don't allocate)          conflicts) and then the rest, so we only free (and don't allocate)
     */      */
     for (i = 0; i < oldsize; i++) {      for (i = 0; i < oldsize; i++) {
        if (oldtable[i].valid == 0)         if (oldtable[i].valid == 0)
             continue;              continue;
         key = xmlHashComputeKey(table, oldtable[i].name, oldtable[i].name2,          key = xmlHashComputeKey(table, oldtable[i].name, oldtable[i].name2,
                                 oldtable[i].name3);                                  oldtable[i].name3);
Line 282  xmlHashGrow(xmlHashTablePtr table, int size) { Line 286  xmlHashGrow(xmlHashTablePtr table, int size) {
                 table->table[key].next = NULL;                  table->table[key].next = NULL;
                 xmlFree(iter);                  xmlFree(iter);
             } else {              } else {
                iter->next = table->table[key].next;                iter->next = table->table[key].next;
                table->table[key].next = iter;                table->table[key].next = iter;
             }              }
   
 #ifdef DEBUG_GROW  #ifdef DEBUG_GROW
Line 599  xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar  Line 603  xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar 
     entry->valid = 1;      entry->valid = 1;
   
   
    if (insert != NULL)     if (insert != NULL)
         insert->next = entry;          insert->next = entry;
   
     table->nbElems++;      table->nbElems++;
Line 748  xmlHashUpdateEntry3(xmlHashTablePtr table, const xmlCh Line 752  xmlHashUpdateEntry3(xmlHashTablePtr table, const xmlCh
  * Returns the a pointer to the userdata   * Returns the a pointer to the userdata
  */   */
 void *  void *
xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name, xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name,
                const xmlChar *name2, const xmlChar *name3) {                 const xmlChar *name2, const xmlChar *name3) {
     unsigned long key;      unsigned long key;
     xmlHashEntryPtr entry;      xmlHashEntryPtr entry;
Line 821  typedef struct { Line 825  typedef struct {
     void *data;      void *data;
 } stubData;  } stubData;
   
static void static void
stubHashScannerFull (void *payload, void *data, const xmlChar *name, stubHashScannerFull (void *payload, void *data, const xmlChar *name,
                      const xmlChar *name2 ATTRIBUTE_UNUSED,                       const xmlChar *name2 ATTRIBUTE_UNUSED,
                      const xmlChar *name3 ATTRIBUTE_UNUSED) {                       const xmlChar *name3 ATTRIBUTE_UNUSED) {
     stubData *stubdata = (stubData *) data;      stubData *stubdata = (stubData *) data;
     stubdata->hashscanner (payload, stubdata->data, (xmlChar *) name);      stubdata->hashscanner (payload, stubdata->data, (xmlChar *) name);
}                                  }
 
 /**  /**
  * xmlHashScan:   * xmlHashScan:
  * @table: the hash table   * @table: the hash table
Line 841  void Line 845  void
 xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data) {  xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data) {
     stubData stubdata;      stubData stubdata;
     stubdata.data = data;      stubdata.data = data;
    stubdata.hashscanner = f;     stubdata.hashscanner = f;
     xmlHashScanFull (table, stubHashScannerFull, &stubdata);      xmlHashScanFull (table, stubHashScannerFull, &stubdata);
 }  }
   
Line 866  xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerF Line 870  xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerF
   
     if (table->table) {      if (table->table) {
         for(i = 0; i < table->size; i++) {          for(i = 0; i < table->size; i++) {
            if (table->table[i].valid == 0)             if (table->table[i].valid == 0)
                 continue;                  continue;
             iter = &(table->table[i]);              iter = &(table->table[i]);
             while (iter) {              while (iter) {
Line 905  xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerF Line 909  xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerF
  * the comparison is considered to match.   * the comparison is considered to match.
  */   */
 void  void
xmlHashScan3(xmlHashTablePtr table, const xmlChar *name, xmlHashScan3(xmlHashTablePtr table, const xmlChar *name,
              const xmlChar *name2, const xmlChar *name3,               const xmlChar *name2, const xmlChar *name3,
              xmlHashScanner f, void *data) {               xmlHashScanner f, void *data) {
     xmlHashScanFull3 (table, name, name2, name3,      xmlHashScanFull3 (table, name, name2, name3,
Line 926  xmlHashScan3(xmlHashTablePtr table, const xmlChar *nam Line 930  xmlHashScan3(xmlHashTablePtr table, const xmlChar *nam
  * the comparison is considered to match.   * the comparison is considered to match.
  */   */
 void  void
xmlHashScanFull3(xmlHashTablePtr table, const xmlChar *name, xmlHashScanFull3(xmlHashTablePtr table, const xmlChar *name,
                  const xmlChar *name2, const xmlChar *name3,                   const xmlChar *name2, const xmlChar *name3,
                  xmlHashScannerFull f, void *data) {                   xmlHashScannerFull f, void *data) {
     int i;      int i;

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>