X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=gmqcc.h;h=8cf2a839bda7c9f353e98683dbb0d93bb2d36d4c;hb=de2e2bd6d3006ad06d2afabb50f25c8a168567a9;hp=5cbf7fe121628c7d8eef80cd400cff2bd22fdce1;hpb=6e047ec65b05c000d509e470e03db4fe37492127;p=xonotic%2Fgmqcc.git diff --git a/gmqcc.h b/gmqcc.h index 5cbf7fe..8cf2a83 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2012 - * Dale Weiler, Wolfgang Bumiller + * Dale Weiler + * Wolfgang Bumiller * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -270,6 +271,13 @@ typedef struct hash_table_t { /* * hashtable implementation: * + * Note: + * This was designed for pointers: you manage the life of the object yourself + * if you do use this for non-pointers please be warned that the object may not + * be valid if the duration of it exceeds (i.e on stack). So you need to allocate + * yourself, or put those in global scope to ensure duration is for the whole + * runtime. + * * util_htnew(size) -- to make a new hashtable * util_htset(table, key, value, sizeof(value)) -- to set something in the table * util_htget(table, key) -- to get something from the table @@ -290,10 +298,13 @@ typedef struct hash_table_t { * * util_htdel(foo); */ -hash_table_t *util_htnew(size_t size); -void util_htset(hash_table_t *ht, const char *key, void *value); -void *util_htget(hash_table_t *ht, const char *key); -void util_htdel(hash_table_t *ht); +hash_table_t *util_htnew (size_t size); +void util_htset (hash_table_t *ht, const char *key, void *value); +void *util_htget (hash_table_t *ht, const char *key); +void util_htdel (hash_table_t *ht); +size_t util_hthash(hash_table_t *ht, const char *key); +void *util_htgeth(hash_table_t *ht, const char *key, size_t hash); +void util_htseth(hash_table_t *ht, const char *key, size_t hash, void *value); /*===================================================================*/ /*=========================== code.c ================================*/ /*===================================================================*/