fix dfb engine - correctness changes for hash

SVN revision: 19845
This commit is contained in:
Carsten Haitzler 2006-01-16 03:37:34 +00:00
parent e754564803
commit 76f7428de7
4 changed files with 58 additions and 26 deletions

View File

@ -210,22 +210,48 @@ evas_hash_del(Evas_Hash *hash, const char *key, const void *data)
Evas_Object_List *l;
if (!hash) return NULL;
hash_num = _evas_hash_gen(key);
for (l = hash->buckets[hash_num]; l; l = l->next)
if (!key)
{
el = (Evas_Hash_El *)l;
if (((key) && (!strcmp(el->key, key))) ||
((!key) && (el->data == data)))
int hash_num;
for (hash_num = 0; hash_num < 256; hash_num++)
{
hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el);
free(el);
hash->population--;
if (hash->population <= 0)
for (l = hash->buckets[hash_num]; l; l = l->next)
{
free(hash);
hash = NULL;
el = (Evas_Hash_El *)l;
if (el->data == data)
{
hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el);
free(el);
hash->population--;
if (hash->population <= 0)
{
free(hash);
hash = NULL;
}
return hash;
}
}
}
}
else
{
hash_num = _evas_hash_gen(key);
for (l = hash->buckets[hash_num]; l; l = l->next)
{
el = (Evas_Hash_El *)l;
if (!strcmp(el->key, key))
{
hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el);
free(el);
hash->population--;
if (hash->population <= 0)
{
free(hash);
hash = NULL;
}
return hash;
}
return hash;
}
}
return hash;

View File

@ -17,7 +17,6 @@
#include <evas_private.h>
Evas_List *evas_modules = NULL;
static Evas_List *evas_module_paths = NULL;
static void
@ -182,6 +181,7 @@ evas_module_init(void)
}
free(buf);
}
closedir(dir);
}
}

View File

@ -1066,7 +1066,7 @@ evas_engine_cairo_x11_image_format_get(void *data, void *image)
/* FIXME */
re = (Render_Engine *)data;
return "";
return NULL;
}
static void

View File

@ -1,4 +1,4 @@
#include "evas_engine_dfb.h"
~#include "evas_engine_dfb.h"
#include <math.h>
#include <string.h>
@ -42,7 +42,7 @@ evas_engine_directfb_image_load(void *data, char *file, char *key, int *error)
*error = 0;
if (!file) return NULL;
mod_time = evas_file_modified_time(file);
// mod_time = evas_file_modified_time(file);
im = _dfb_image_find(file, key, mod_time);
if (im)
{
@ -84,7 +84,7 @@ evas_engine_directfb_image_load(void *data, char *file, char *key, int *error)
if (img_desc.caps & DICAPS_ALPHACHANNEL)
im->flags |= RGBA_IMAGE_HAS_ALPHA;
im->timestamp = mod_time;
// im->timestamp = mod_time;
if (file)
im->info.file = strdup(file);
if (key)
@ -705,8 +705,10 @@ _dfb_image_store(RGBA_Image *im)
if (im->info.file) l1 = strlen(im->info.file);
l2 = 0;
if (im->info.key) l2 = strlen(im->info.key);
snprintf(buf, sizeof(buf), "%llx", im->timestamp);
l3 = strlen(buf);
// snprintf(buf, sizeof(buf), "%llx", im->timestamp);
// l3 = strlen(buf);
buf[0] = 0;
l3 = 0;
key = malloc(l1 + 3 + l2 + 3 + l3 +1);
if (!key) return;
key[0] = 0;
@ -733,8 +735,10 @@ _dfb_image_unstore(RGBA_Image *im)
if (im->info.file) l1 = strlen(im->info.file);
l2 = 0;
if (im->info.key) l2 = strlen(im->info.key);
snprintf(buf, sizeof(buf), "%llx", im->timestamp);
l3 = strlen(buf);
// snprintf(buf, sizeof(buf), "%llx", im->timestamp);
// l3 = strlen(buf);
buf[0] = 0;
l3 = 0;
key = malloc(l1 + 3 + l2 + 3 + l3 +1);
if (!key) return;
key[0] = 0;
@ -763,8 +767,10 @@ _dfb_image_find(const char *filename, const char *key, DATA64 timestamp)
if (filename) l1 = strlen(filename);
l2 = 0;
if (key) l2 = strlen(key);
sprintf(buf, "%llx", timestamp);
l3 = strlen(buf);
// sprintf(buf, "%llx", timestamp);
// l3 = strlen(buf);
buf[0] = 0;
l3 = 0;
str = malloc(l1 + 3 + l2 + 3 + l3 +1);
if (!str) return NULL;
str[0] = 0;
@ -793,9 +799,9 @@ _dfb_image_find(const char *filename, const char *key, DATA64 timestamp)
ok++;
if ((!key) && (!im->info.key))
ok++;
if (im->timestamp == timestamp)
ok++;
if (ok >= 3) return im;
// if (im->timestamp == timestamp)
// ok++;
if (ok >= 2) return im;
}
return NULL;
}