Diff for /libelwix/src/index.c between versions 1.1.2.2 and 1.1.2.3

version 1.1.2.2, 2022/01/04 22:56:53 version 1.1.2.3, 2022/01/05 23:03:40
Line 81  index_FreeList(index_list_t __restrict lst) Line 81  index_FreeList(index_list_t __restrict lst)
  * index_FreeLists() - Free linked lists with data   * index_FreeLists() - Free linked lists with data
  *   *
  * @idx = index   * @idx = index
 * return: no result * return: none
  */   */
 void  void
 index_FreeLists(index_t *idx)  index_FreeLists(index_t *idx)
Line 97  index_FreeLists(index_t *idx) Line 97  index_FreeLists(index_t *idx)
  * index_Destroy() - Destroy index   * index_Destroy() - Destroy index
  *   *
  * @idx = index   * @idx = index
 * return: no result * return: none
  */   */
 void  void
 index_Destroy(index_t **idx)  index_Destroy(index_t **idx)
Line 126  index_getArray(index_t *idx, u_short key) Line 126  index_getArray(index_t *idx, u_short key)
         if (!idx)          if (!idx)
                 return NULL;                  return NULL;
   
        for (n = 0, lst = index_get(idx, key); lst; n++, lst = lst->il_next);        for (n = 0, lst = index_getList(idx, key); lst; n++, lst = lst->il_next);
         arr = array_Init(n);          arr = array_Init(n);
         if (!arr)          if (!arr)
                 return NULL;                  return NULL;
        for (n = 0, lst = index_get(idx, key); lst; n++, lst = lst->il_next)        for (n = 0, lst = index_getList(idx, key); lst; n++, lst = lst->il_next)
                 array_Set(arr, n, lst);                  array_Set(arr, n, lst);
   
         return arr;          return arr;
Line 239  index_delList(index_t *idx, u_short key) Line 239  index_delList(index_t *idx, u_short key)
 }  }
   
 /*  /*
    * index_del2() - Dels item with index key and hash
    *
    * @idx = index
    * @key = hash key
    * @hash = calculated hash of item when its added to index
    * return: -1 error, 0 nothing deleted and 1 item deleted
    */
   int
   index_del2(index_t *idx, u_short key, u_int hash)
   {
           index_list_t lst, prev;
   
           if (!idx)
                   return -1;
   
           lst = idx->i_hash[key];
           if (!lst)
                   return 0;
   
           if (lst->il_hash == hash) {
                   idx->i_hash[key] = lst->il_next;
                   e_free(lst);
                   return 1;       /* deleted item */
           } else {
                   prev = lst;
                   lst = lst->il_next;
           }
           while (lst) {
                   if (lst->il_hash == hash) {
                           prev->il_next = lst->il_next;
                           e_free(lst);
                           return 1;       /* deleted item */
                   } else {
                           prev = lst;
                           lst = lst->il_next;
                   }
           }
   
           return 0;
   }
   
   /*
  * index_get2() - Get item by key and hash   * index_get2() - Get item by key and hash
  *   *
  * @idx = index   * @idx = index
Line 291  index_getVar(index_t *idx, u_short key, u_int hash) Line 333  index_getVar(index_t *idx, u_short key, u_int hash)
   
         AIT_SET_PTR(v, lst->il_ptr, lst->il_len);          AIT_SET_PTR(v, lst->il_ptr, lst->il_len);
         return v;          return v;
   }
   
   /*
    * index_dump() - Debug routine about index hashes
    *
    * @idx = index
    * return: none
    */
   void
   index_dump(index_t *idx)
   {
           index_list_t lst;
           register int i;
   
           for (i = 0; i < 65536; i++) {
                   lst = idx->i_hash[i];
                   while (lst) {
                           printf("index[%hu/0x%x]=%s length=%lu\n", (u_short) i, index_Hash(lst), 
                                           (const char*) index_Ptr(lst), index_Len(lst));
                           lst = lst->il_next;
                   }
           }
 }  }

Removed from v.1.1.2.2  
changed lines
  Added in v.1.1.2.3


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