Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Weikert <elubie@gmx.net>2005-12-22 01:21:43 +0300
committerAndrea Weikert <elubie@gmx.net>2005-12-22 01:21:43 +0300
commit80eb4d3b9e851c19638599b1821a083dc5a2f635 (patch)
treebfb42679c33f19c498d3f682924ffc3e40a5d482 /source/blender/blenlib/intern/BLI_ghash.c
parent15766e1612040c41ed66fe618af1d28ab3c6d1ec (diff)
Big commit in orange: Interface icons for materials, textures
world and lamp. Also for images in pupmenus. Also preparation for work on using preview images in imagebrowser. -- Andrea
Diffstat (limited to 'source/blender/blenlib/intern/BLI_ghash.c')
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 23e21d4fb45..bc0f79d2cc4 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -128,6 +128,34 @@ void* BLI_ghash_lookup(GHash *gh, void *key) {
return NULL;
}
+int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
+{
+ unsigned int hash= gh->hashfp(key)%gh->nbuckets;
+ Entry *e;
+ Entry *p = 0;
+
+ for (e= gh->buckets[hash]; e; e= e->next) {
+ if (gh->cmpfp(key, e->key)==0) {
+ Entry *n= e->next;
+
+ if (keyfreefp) keyfreefp(e->key);
+ if (valfreefp) valfreefp(e->val);
+ free(e);
+
+
+ e= n;
+ if (p)
+ p->next = n;
+ else
+ gh->buckets[hash] = n;
+ return 1;
+ }
+ p = e;
+ }
+
+ return 0;
+}
+
int BLI_ghash_haskey(GHash *gh, void *key) {
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
Entry *e;
@@ -161,6 +189,9 @@ void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreef
}
free(gh->buckets);
+ gh->buckets = 0;
+ gh->nentries = 0;
+ gh->nbuckets = 0;
MEM_freeN(gh);
}
@@ -223,6 +254,30 @@ int BLI_ghashutil_ptrcmp(void *a, void *b) {
return (a<b)?-1:1;
}
+unsigned int BLI_ghashutil_inthash(void *ptr) {
+#if defined(_WIN64)
+ unsigned __int64 key = (unsigned __int64)ptr;
+#else
+ unsigned long key = (unsigned long)ptr;
+#endif
+
+ key += ~(key << 16);
+ key ^= (key >> 5);
+ key += (key << 3);
+ key ^= (key >> 13);
+ key += ~(key << 9);
+ key ^= (key >> 17);
+
+ return (unsigned int)(key & 0xffffffff);
+}
+
+int BLI_ghashutil_intcmp(void *a, void *b) {
+ if (a==b)
+ return 0;
+ else
+ return (a<b)?-1:1;
+}
+
unsigned int BLI_ghashutil_strhash(void *ptr) {
char *s= ptr;
unsigned int i= 0;