Logo Search packages:      
Sourcecode: zoem version File versions

ops-constant.c

/*      Copyright (C) 2001, 2002, 2003, 2004 Stijn van Dongen
 *
 * This file is part of Zoem. You can redistribute and/or modify Zoem under the
 * terms of the GNU General Public License;  either version 2 of the License or
 * (at your option) any later  version.  You should have received a copy of the
 * GPL along with Zoem, in the file COPYING.
*/

#include "ops-constant.h"
#include "filter.h"
#include "util.h"
#include "curly.h"

#include "util/hash.h"
#include "util/ting.h"

static   mcxHash*    cstTable_g        =  NULL;    /* constants         */


mcxTing* yamConstantGet
(  mcxTing* key
)
   {  mcxKV*   kv =  (mcxKV*) mcxHashSearch(key, cstTable_g, MCX_DATUM_FIND)
   ;  return kv ? (mcxTing*) kv->val : NULL
;  }


/* fixme
 * is key really owned by  yCN?
*/

mcxTing* yamConstantNew
(  mcxTing* key
,  const char* val
)
   {  mcxKV*   kv =  (mcxKV*) mcxHashSearch(key, cstTable_g, MCX_DATUM_INSERT)

   ;  if ((mcxTing*) kv->key != key)
      mcxTingWrite((mcxTing*)kv->val, val)
   ;  else
      kv->val = mcxTingNew(val)

   ;  return (mcxTing*) kv->key
;  }


void mod_constant_init
(  int n
)
   {  cstTable_g           =  yamHashNew(n)
;  }


void mod_constant_exit
(  void
)
   {  mcxHashFree(&cstTable_g, mcxTingFree_v, mcxTingFree_v)
;  }



Generated by  Doxygen 1.6.0   Back to index