aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eet/src/lib/eet_dictionary.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eet/src/lib/eet_dictionary.c')
-rw-r--r--libraries/eet/src/lib/eet_dictionary.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/libraries/eet/src/lib/eet_dictionary.c b/libraries/eet/src/lib/eet_dictionary.c
index 60d0ec1..287860d 100644
--- a/libraries/eet/src/lib/eet_dictionary.c
+++ b/libraries/eet/src/lib/eet_dictionary.c
@@ -16,34 +16,33 @@ eet_dictionary_add(void)
16{ 16{
17 Eet_Dictionary *new; 17 Eet_Dictionary *new;
18 18
19 new = calloc(1, sizeof (Eet_Dictionary)); 19 new = eet_dictionary_calloc(1);
20 if (!new) 20 if (!new)
21 return NULL; 21 return NULL;
22 22
23 memset(new->hash, -1, sizeof (int) * 256); 23 memset(new->hash, -1, sizeof (int) * 256);
24 24
25 return new; 25 return new;
26} /* eet_dictionary_add */ 26}
27 27
28void 28void
29eet_dictionary_free(Eet_Dictionary *ed) 29eet_dictionary_free(Eet_Dictionary *ed)
30{ 30{
31 if (ed) 31 int i;
32 {
33 int i;
34 32
35 for (i = 0; i < ed->count; ++i) 33 if (!ed) return;
36 if (ed->all[i].allocated)
37 eina_stringshare_del(ed->all[i].str);
38 34
39 if (ed->all) 35 for (i = 0; i < ed->count; ++i)
40 free(ed->all); 36 if (ed->all[i].allocated)
37 eina_stringshare_del(ed->all[i].str);
41 38
42 if (ed->converts) eina_hash_free(ed->converts); 39 if (ed->all)
40 free(ed->all);
43 41
44 free(ed); 42 if (ed->converts) eina_hash_free(ed->converts);
45 } 43
46} /* eet_dictionary_free */ 44 eet_dictionary_mp_free(ed);
45}
47 46
48static int 47static int
49_eet_dictionary_lookup(Eet_Dictionary *ed, 48_eet_dictionary_lookup(Eet_Dictionary *ed,
@@ -77,7 +76,7 @@ _eet_dictionary_lookup(Eet_Dictionary *ed,
77 return prev; 76 return prev;
78 77
79 return current; 78 return current;
80} /* _eet_dictionary_lookup */ 79}
81 80
82int 81int
83eet_dictionary_string_add(Eet_Dictionary *ed, 82eet_dictionary_string_add(Eet_Dictionary *ed,
@@ -110,7 +109,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
110 109
111 total = ed->total + 8; 110 total = ed->total + 8;
112 111
113 new = realloc(ed->all, sizeof (Eet_String) * total); 112 new = realloc(ed->all, total * sizeof(Eet_String));
114 if (!new) 113 if (!new)
115 return -1; 114 return -1;
116 115
@@ -152,7 +151,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
152 } 151 }
153 152
154 return ed->count++; 153 return ed->count++;
155} /* eet_dictionary_string_add */ 154}
156 155
157int 156int
158eet_dictionary_string_get_size(const Eet_Dictionary *ed, 157eet_dictionary_string_get_size(const Eet_Dictionary *ed,
@@ -168,7 +167,7 @@ eet_dictionary_string_get_size(const Eet_Dictionary *ed,
168 return ed->all[idx].len; 167 return ed->all[idx].len;
169 168
170 return 0; 169 return 0;
171} /* eet_dictionary_string_get_size */ 170}
172 171
173int 172int
174eet_dictionary_string_get_hash(const Eet_Dictionary *ed, 173eet_dictionary_string_get_hash(const Eet_Dictionary *ed,
@@ -184,7 +183,7 @@ eet_dictionary_string_get_hash(const Eet_Dictionary *ed,
184 return ed->all[idx].hash; 183 return ed->all[idx].hash;
185 184
186 return -1; 185 return -1;
187} /* eet_dictionary_string_get_hash */ 186}
188 187
189const char * 188const char *
190eet_dictionary_string_get_char(const Eet_Dictionary *ed, 189eet_dictionary_string_get_char(const Eet_Dictionary *ed,
@@ -210,7 +209,7 @@ eet_dictionary_string_get_char(const Eet_Dictionary *ed,
210 } 209 }
211 210
212 return NULL; 211 return NULL;
213} /* eet_dictionary_string_get_char */ 212}
214 213
215static inline Eina_Bool 214static inline Eina_Bool
216_eet_dictionary_string_get_me_cache(const char *s, 215_eet_dictionary_string_get_me_cache(const char *s,
@@ -227,7 +226,7 @@ _eet_dictionary_string_get_me_cache(const char *s,
227 } 226 }
228 227
229 return EINA_FALSE; 228 return EINA_FALSE;
230} /* _eet_dictionary_string_get_me_cache */ 229}
231 230
232static inline Eina_Bool 231static inline Eina_Bool
233_eet_dictionary_string_get_float_cache(const char *s, 232_eet_dictionary_string_get_float_cache(const char *s,
@@ -248,7 +247,7 @@ _eet_dictionary_string_get_float_cache(const char *s,
248 } 247 }
249 248
250 return EINA_FALSE; 249 return EINA_FALSE;
251} /* _eet_dictionary_string_get_float_cache */ 250}
252 251
253static inline Eina_Bool 252static inline Eina_Bool
254_eet_dictionary_string_get_double_cache(const char *s, 253_eet_dictionary_string_get_double_cache(const char *s,
@@ -269,7 +268,7 @@ _eet_dictionary_string_get_double_cache(const char *s,
269 } 268 }
270 269
271 return EINA_FALSE; 270 return EINA_FALSE;
272} /* _eet_dictionary_string_get_double_cache */ 271}
273 272
274static inline Eina_Bool 273static inline Eina_Bool
275_eet_dictionary_test(const Eet_Dictionary *ed, 274_eet_dictionary_test(const Eet_Dictionary *ed,
@@ -289,7 +288,7 @@ _eet_dictionary_test(const Eet_Dictionary *ed,
289 return EINA_FALSE; 288 return EINA_FALSE;
290 289
291 return EINA_TRUE; 290 return EINA_TRUE;
292} /* _eet_dictionary_test */ 291}
293 292
294static Eet_Convert * 293static Eet_Convert *
295eet_dictionary_convert_get(const Eet_Dictionary *ed, 294eet_dictionary_convert_get(const Eet_Dictionary *ed,
@@ -351,7 +350,7 @@ eet_dictionary_string_get_float(const Eet_Dictionary *ed,
351 350
352 *result = convert->f; 351 *result = convert->f;
353 return EINA_TRUE; 352 return EINA_TRUE;
354} /* eet_dictionary_string_get_float */ 353}
355 354
356Eina_Bool 355Eina_Bool
357eet_dictionary_string_get_double(const Eet_Dictionary *ed, 356eet_dictionary_string_get_double(const Eet_Dictionary *ed,
@@ -387,7 +386,7 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed,
387 386
388 *result = convert->d; 387 *result = convert->d;
389 return EINA_TRUE; 388 return EINA_TRUE;
390} /* eet_dictionary_string_get_double */ 389}
391 390
392Eina_Bool 391Eina_Bool
393eet_dictionary_string_get_fp(const Eet_Dictionary *ed, 392eet_dictionary_string_get_fp(const Eet_Dictionary *ed,
@@ -416,7 +415,7 @@ eet_dictionary_string_get_fp(const Eet_Dictionary *ed,
416 415
417 *result = convert->fp; 416 *result = convert->fp;
418 return EINA_TRUE; 417 return EINA_TRUE;
419} /* eet_dictionary_string_get_fp */ 418}
420 419
421EAPI int 420EAPI int
422eet_dictionary_string_check(Eet_Dictionary *ed, 421eet_dictionary_string_check(Eet_Dictionary *ed,
@@ -435,5 +434,5 @@ eet_dictionary_string_check(Eet_Dictionary *ed,
435 return 1; 434 return 1;
436 435
437 return 0; 436 return 0;
438} /* eet_dictionary_string_check */ 437}
439 438