diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-03-05 04:01:34 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-03-05 04:01:34 +0000 |
commit | 0881211a12597bdda1cb944b8027d36ba0f53f7b (patch) | |
tree | af35a38656777fac8b6a26d652332fd7958e197e /epan/emem.h | |
parent | 49de5e663ec76ada7fc2377deb22285497273047 (diff) |
initial implementation of binary tree support with se allocation scope
this is to test out a basic implementation of binary trees and the api required for the helpers
svn path=/trunk/; revision=17467
Diffstat (limited to 'epan/emem.h')
-rw-r--r-- | epan/emem.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/epan/emem.h b/epan/emem.h index 2e48ed93c5..e4b8f5e000 100644 --- a/epan/emem.h +++ b/epan/emem.h @@ -155,4 +155,43 @@ gchar* se_strdup_printf(const gchar* fmt, ...) void se_free_all(void); + + +/************************************************************** + * binary trees with SE allocation + **************************************************************/ +#define SE_TREE_RB_COLOR_RED 0x00 +#define SE_TREE_RB_COLOR_BLACK 0x01 +typedef struct _se_tree_node_t { + struct _se_tree_node_t *parent; + struct _se_tree_node_t *left; + struct _se_tree_node_t *right; + union { + guint32 rb_color; + }; + guint32 key32; + void *data; +} se_tree_node_t; + +/* list of all se trees so they can all be reset automatically when + * we free all se memory + */ +/* Right now we only do basic red/black trees but in the future we might want + * to try something different, such as a tree where each node keeps track + * of how many times it has been looked up, and letting often looked up + * nodes bubble upwards in the tree using rotate_right/left. + * That would probably be good for things like nfs filehandles + */ +#define SE_TREE_TYPE_RED_BLACK 1 +typedef struct _se_tree_t { + struct _se_tree_t *next; + int type; + se_tree_node_t *tree; +} se_tree_t; +extern se_tree_t *se_trees; + +se_tree_t *se_tree_create(int type); +void se_tree_insert32(se_tree_t *se_tree, guint32 key, void *data); +void *se_tree_lookup32(se_tree_t *se_tree, guint32 key); + #endif /* emem.h */ |