Data structures in Gcc

Please expand the notes to include examples you find useful.

Vector

The file vec.h specifies the interface equivalent of a template class library for variable size vectors. For example

      list = VEC_alloc (data_struct*, heap, num_elements);
      VEC_quick_push (data_struct*, list, new_elem);

Hash table

The interface is specified in include/hashtab.h. To allocate and use, try exploring some uses in Gcc, one of which is the following in cgraph_node() in cgraph.c.

static GTY((param_is (struct cgraph_node))) htab_t cgraph_hash;

 if (!cgraph_hash)
     cgraph_hash = htab_create_ggc (10, hash_node, eq_test, NULL);
 
 slot = (struct cgraph_node **) htab_find_slot (cgraph_hash, &key, INSERT);
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r2 - 2008-03-14 - ChenDing
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback