Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/include/hashtab.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* An expandable hash tables datatype. 
    2    Copyright (C) 1999, 2000 Free Software Foundation, Inc.
     2   Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
    33   Contributed by Vladimir Makarov (vmakarov@cygnus.com).
    44
     
    3737#endif /* __cplusplus */
    3838
    39 #include <ansidecl.h>
     39#include "ansidecl.h"
     40
     41#ifndef GTY
     42#define GTY(X)
     43#endif
    4044
    4145/* The type for a hash code.  */
     
    6468typedef int (*htab_trav) PARAMS ((void **, void *));
    6569
     70/* Memory-allocation function, with the same functionality as calloc().
     71   Iff it returns NULL, the hash table implementation will pass an error
     72   code back to the user, so if your code doesn't handle errors,
     73   best if you use xcalloc instead.  */
     74typedef PTR (*htab_alloc) PARAMS ((size_t, size_t));
     75
     76/* We also need a free() routine.  */
     77typedef void (*htab_free) PARAMS ((PTR));
     78
     79/* Memory allocation and deallocation; variants which take an extra
     80   argument.  */
     81typedef PTR (*htab_alloc_with_arg) PARAMS ((void *, size_t, size_t));
     82typedef void (*htab_free_with_arg) PARAMS ((void *, void *));
     83
    6684/* Hash tables are of the following type.  The structure
    6785   (implementation) of this type is not needed for using the hash
    6886   tables.  All work with hash table should be executed only through
    69    functions mentioned below. */
     87   functions mentioned below.  The size of this structure is subject to
     88   change.  */
    7089
    71 struct htab
     90struct htab GTY(())
    7291{
    7392  /* Pointer to hash function.  */
     
    81100
    82101  /* Table itself.  */
    83   PTR *entries;
     102  PTR * GTY ((use_param (""), length ("%h.size"))) entries;
    84103
    85104  /* Current size (in entries) of the hash table */
     
    100119  unsigned int collisions;
    101120
    102   /* This is non-zero if we are allowed to return NULL for function calls
    103      that allocate memory.  */
    104   int return_allocation_failure;
     121  /* Pointers to allocate/free functions.  */
     122  htab_alloc alloc_f;
     123  htab_free free_f;
     124
     125  /* Alternate allocate/free functions, which take an extra argument.  */
     126  PTR GTY((skip (""))) alloc_arg;
     127  htab_alloc_with_arg alloc_with_arg_f;
     128  htab_free_with_arg free_with_arg_f;
    105129};
    106130
     
    112136/* The prototypes of the package functions. */
    113137
    114 extern htab_t   htab_create     PARAMS ((size_t, htab_hash,
    115                                          htab_eq, htab_del));
     138extern htab_t   htab_create_alloc       PARAMS ((size_t, htab_hash,
     139                                                 htab_eq, htab_del,
     140                                                 htab_alloc, htab_free));
    116141
    117 /* This function is like htab_create, but may return NULL if memory
    118    allocation fails, and also signals that htab_find_slot_with_hash and
    119    htab_find_slot are allowed to return NULL when inserting.  */
    120 extern htab_t   htab_try_create PARAMS ((size_t, htab_hash,
    121                                          htab_eq, htab_del));
     142extern htab_t   htab_create_alloc_ex    PARAMS ((size_t, htab_hash,
     143                                                    htab_eq, htab_del,
     144                                                    PTR, htab_alloc_with_arg,
     145                                                    htab_free_with_arg));
     146
     147/* Backward-compatibility functions.  */
     148extern htab_t htab_create PARAMS ((size_t, htab_hash, htab_eq, htab_del));
     149extern htab_t htab_try_create PARAMS ((size_t, htab_hash, htab_eq, htab_del));
     150
     151extern void     htab_set_functions_ex   PARAMS ((htab_t, htab_hash,
     152                                                 htab_eq, htab_del,
     153                                                 PTR, htab_alloc_with_arg,
     154                                                 htab_free_with_arg));
     155
    122156extern void     htab_delete     PARAMS ((htab_t));
    123157extern void     htab_empty      PARAMS ((htab_t));
     
    135169
    136170extern void     htab_traverse   PARAMS ((htab_t, htab_trav, void *));
     171extern void     htab_traverse_noresize  PARAMS ((htab_t, htab_trav, void *));
    137172
    138173extern size_t   htab_size       PARAMS ((htab_t));
     
    146181extern htab_eq htab_eq_pointer;
    147182
     183/* A hash function for null-terminated strings.  */
     184extern hashval_t htab_hash_string PARAMS ((const PTR));
     185
    148186#ifdef __cplusplus
    149187}
Note: See TracChangeset for help on using the changeset viewer.