[teklib-general] teklib: Visual: Added VISUAL_USE_INTERNAL_HASH compile-time option
Timm S. Mueller
tmueller at neoscientists.org
Mon Jul 13 10:13:51 CEST 2009
details: http://hg.teklib.org/teklib/rev/c12478e8e02b
changeset: 266:c12478e8e02b
user: Timm S. Mueller <tmueller at neoscientists.org>
date: Sun Jun 14 15:45:03 2009 +0200
description:
Visual: Added VISUAL_USE_INTERNAL_HASH compile-time option
diffs (truncated from 216 to 100 lines):
diff -r 4eab5b6033cc -r c12478e8e02b src/visual/visual_api.c
--- a/src/visual/visual_api.c Sun Jun 14 15:06:18 2009 +0200
+++ b/src/visual/visual_api.c Sun Jun 14 15:45:03 2009 +0200
@@ -5,6 +5,61 @@
#define DEF_DISPLAYNAME "display_windows"
#else
#define DEF_DISPLAYNAME "display_x11"
+#endif
+
+/*****************************************************************************/
+
+#if !defined(VISUAL_USE_INTERNAL_HASH)
+
+LOCAL struct vis_Hash *vis_createhash(struct TVisualBase *mod, TAPTR udata)
+{
+ struct TExecBase *TExecBase = TGetExecBase(mod);
+ mod->vis_UtilBase = TOpenModule("util", 0, TNULL);
+ if (mod->vis_UtilBase)
+ {
+ TTAGITEM tags[2];
+ TAPTR hash;
+ tags[0].tti_Tag = THash_Type;
+ tags[0].tti_Value = THASHTYPE_STRINGCOPY;
+ tags[1].tti_Tag = TTAG_DONE;
+ hash = TUtilCreateHash(mod->vis_UtilBase, tags);
+ if (hash)
+ return hash;
+ vis_destroyhash(mod, TNULL);
+ }
+ return TNULL;
+}
+
+LOCAL void vis_destroyhash(struct TVisualBase *mod, struct vis_Hash *hash)
+{
+ struct TExecBase *TExecBase = TGetExecBase(mod);
+ if (hash)
+ TDestroy((struct THandle *) hash);
+ if (mod->vis_UtilBase)
+ TCloseModule(mod->vis_UtilBase);
+ mod->vis_UtilBase = TNULL;
+}
+
+LOCAL int vis_puthash(struct TVisualBase *mod, struct vis_Hash *hash,
+ const TSTRPTR key, TTAG value)
+{
+ return TUtilPutHash(mod->vis_UtilBase, (struct THash *) hash,
+ (TTAG) key, value);
+}
+
+LOCAL int vis_gethash(struct TVisualBase *mod, struct vis_Hash *hash,
+ const TSTRPTR key, TTAG *valp)
+{
+ return TUtilGetHash(mod->vis_UtilBase, (struct THash *) hash,
+ (TTAG) key, valp);
+}
+
+LOCAL TUINT vis_hashtolist(struct TVisualBase *mod, struct vis_Hash *hash,
+ struct TList *list)
+{
+ return TUtilHashToList(mod->vis_UtilBase, (struct THash *) hash, list);
+}
+
#endif
/*****************************************************************************/
@@ -570,8 +625,7 @@
/* lookup display by name: */
TLock(mod->vis_Lock);
- success = TUtilGetHash(mod->vis_UtilBase, mod->vis_Displays,
- (TTAG) name, &hashval);
+ success = vis_gethash(mod, mod->vis_Displays, name, &hashval);
TUnlock(mod->vis_Lock);
if (success)
@@ -585,8 +639,8 @@
{
/* store display in hash: */
TLock(mod->vis_Lock);
- success = TUtilPutHash(mod->vis_UtilBase, mod->vis_Displays,
- (TTAG) name, (TTAG) display);
+ success = vis_puthash(mod, mod->vis_Displays, name,
+ (TTAG) display);
TUnlock(mod->vis_Lock);
if (!success)
diff -r 4eab5b6033cc -r c12478e8e02b src/visual/visual_mod.c
--- a/src/visual/visual_mod.c Sun Jun 14 15:06:18 2009 +0200
+++ b/src/visual/visual_mod.c Sun Jun 14 15:45:03 2009 +0200
@@ -248,17 +248,11 @@
static TBOOL
vis_init(struct TVisualBase *mod)
{
- struct TExecBase *TExecBase = TGetExecBase(mod);
for (;;)
{
- TTAGITEM tags[2];
- mod->vis_UtilBase = TOpenModule("util", 0, TNULL);
- if (mod->vis_UtilBase == TNULL) break;
- tags[0].tti_Tag = THash_Type;
More information about the teklib-general
mailing list