* Makefile.in, configure.in, configure,
[fw/sdcc] / src / SDCChasht.h
index 2d8536315af684e2d3e70df1d39bb9a04cf0437c..89013cc5fa893ae2061a85c29443025d583fed85 100644 (file)
 #ifndef SDCCHASHT_H
 #define SDCCHASHT_H
 
-#ifdef _NO_GC
-
-#include <stdlib.h>
-#define GC_malloc malloc
-#define GC_free free
-#define GC_realloc realloc
-#define GC_malloc_atomic malloc
-
-#else
-
-#include "./gc/gc.h" 
-
-#endif
-
-#ifndef ALLOC
-
-#define  ALLOC(x,sz) if (!(x = GC_malloc(sz)))                          \
-         {                                                           \
-            fprintf(stderr,"out of virtual memory %s , %d",__FILE__,__LINE__);\
-            exit (1);                                                \
-         }
-
-#define  ALLOC_ATOMIC(x,sz) if (!(x = GC_malloc_atomic(sz)))                          \
-         {                                                           \
-            fprintf(stderr,"out of virtual memory %s , %d",__FILE__,__LINE__);\
-            exit (1);                                                \
-         }
-
-
-
-#endif
 
 
 /* hashtable item */
 typedef struct hashtItem
-{
+  {
     int key;
     /* Pointer to the key that was hashed for key.
        Used for a hash table with unique keys. */
     void *pkey;
     void *item;
-    struct hashtItem *next ;
-} hashtItem ;
+    struct hashtItem *next;
+  }
+hashtItem;
 
 /* hashtable */
 typedef struct hTab
-{
-    int size  ;             /* max number of items */
-    int minKey;             /* minimum key value   */
-    int maxKey ;            /* maximum key value */
-    hashtItem **table ;     /* the actual table  */
-    int currKey  ;          /* used for iteration */
-    hashtItem *currItem ;   /* current item within the list */
-    int nItems ;
-} hTab ;
-
-typedef enum {
+  {
+    int size;                  /* max number of items */
+    int minKey;                        /* minimum key value   */
+    int maxKey;                        /* maximum key value */
+    hashtItem **table;         /* the actual table  */
+    int currKey;               /* used for iteration */
+    hashtItem *currItem;       /* current item within the list */
+    int nItems;
+  }
+hTab;
+
+typedef enum
+  {
     DELETE_CHAIN = 1,
-    DELETE_ITEM 
-} DELETE_ACTION;
+    DELETE_ITEM
+  }
+DELETE_ACTION;
 
 
 /*-----------------------------------------------------------------*/
-/*          Forward   definition    for   functions               */
+/*           Forward   definition    for   functions               */
 /*-----------------------------------------------------------------*/
 
 /* hashtable related functions */
-hTab        *newHashTable      (int);
-void         hTabAddItem (hTab **, int key, void *item);
+hTab *newHashTable (int);
+void hTabAddItem (hTab **, int key, void *item);
 /** Adds a new item to the hash table.
     @param h           The hash table to add to
     @param key         A hashed version of pkey
@@ -102,7 +75,7 @@ void         hTabAddItem (hTab **, int key, void *item);
                        hash table after this function.
     @param item                Value for this key.
 */
-void        hTabAddItemLong(hTab **h, int key, void *pkey, void *item);
+void hTabAddItemLong (hTab ** h, int key, void *pkey, void *item);
 /** Finds a item by exact key.
     Searches all items in the key 'key' for a key that
     according to 'compare' matches pkey.
@@ -111,37 +84,38 @@ void            hTabAddItemLong(hTab **h, int key, void *pkey, void *item);
     @param pkey                The key to search for
     @param compare     Returns 0 if pkey == this
 */
-void *      hTabFindByKey(hTab *h, int key, const void *pkey, int (*compare)(const void *, const void *));
+void *hTabFindByKey (hTab * h, int key, const void *pkey, int (*compare) (const void *, const void *));
 /** Deletes an item with the exact key 'pkey'
     @see hTabFindByKey
 */
-int         hTabDeleteByKey(hTab **h, int key, const void *pkey, int (*compare)(const void *, const void *));
-
-void         hTabDeleteItem (hTab **, int key,
-                            const void *item, DELETE_ACTION action,
-                            int (*compareFunc)(const void *,const void *));
-int          hTabIsInTable (hTab *, int , void * , 
-                                int (*compareFunc)(void *,void *));
-void         *hTabFirstItem (hTab *, int *);
-void         *hTabNextItem (hTab *, int *);
-hTab         *hTabFromTable (hTab *);
-int          isHtabsEqual (hTab *,hTab *, int (*compareFunc)(void *,void *));
-hashtItem    *hTabSearch  (hTab *, int );
-void         *hTabItemWithKey(hTab *,int );
-void         hTabAddItemIfNotP(hTab **,int, void *);
-void         hTabDeleteAll(hTab *);
-void        *hTabFirstItemWK (hTab *htab, int wk);
-void        *hTabNextItemWK (hTab *htab );
-void         hTabClearAll (hTab *htab);
+int hTabDeleteByKey (hTab ** h, int key, const void *pkey, int (*compare) (const void *, const void *));
+
+void hTabDeleteItem (hTab **, int key,
+                    const void *item, DELETE_ACTION action,
+                    int (*compareFunc) (const void *, const void *));
+int hTabIsInTable (hTab *, int, void *,
+                  int (*compareFunc) (void *, void *));
+void *hTabFirstItem (hTab *, int *);
+void *hTabNextItem (hTab *, int *);
+hTab *hTabFromTable (hTab *);
+int isHtabsEqual (hTab *, hTab *, int (*compareFunc) (void *, void *));
+hashtItem *hTabSearch (hTab *, int);
+void *hTabItemWithKey (hTab *, int);
+void hTabAddItemIfNotP (hTab **, int, void *);
+void hTabDeleteAll (hTab *);
+void *hTabFirstItemWK (hTab * htab, int wk);
+void *hTabNextItemWK (hTab * htab);
+void hTabClearAll (hTab * htab);
+int hTabMaxKey (hTab *htab);
 
 /** Find the first item that either is 'item' or which
     according to 'compareFunc' is the same as item.
     @param compareFunc         strcmp like compare function, may be null.
 */
-void *hTabFindItem(hTab *htab, int key, 
-                  void *item, int (*compareFunc)(void *,void *));
+void *hTabFindItem (hTab * htab, int key,
+                   void *item, int (*compareFunc) (void *, void *));
 
-void shash_add(hTab **h, const char *szKey, const char *szValue);
-const char *shash_find(hTab *h, const char *szKey);
+void shash_add (hTab ** h, const char *szKey, const char *szValue);
+const char *shash_find (hTab * h, const char *szKey);
 
 #endif