Lines Matching refs:cm

183 mapper_close(struct _citrus_mapper *cm)
185 if (cm->cm_module) {
186 if (cm->cm_ops) {
187 if (cm->cm_closure)
188 (*cm->cm_ops->mo_uninit)(cm);
189 free(cm->cm_ops);
191 _citrus_unload_module(cm->cm_module);
193 free(cm->cm_traits);
194 free(cm);
207 struct _citrus_mapper *cm;
212 cm = malloc(sizeof(*cm));
213 if (!cm)
216 cm->cm_module = NULL;
217 cm->cm_ops = NULL;
218 cm->cm_closure = NULL;
219 cm->cm_traits = NULL;
220 cm->cm_refcount = 0;
221 cm->cm_key = NULL;
224 ret = _citrus_load_module(&cm->cm_module, module);
230 _citrus_find_getops(cm->cm_module, module, "mapper");
235 cm->cm_ops = malloc(sizeof(*cm->cm_ops));
236 if (!cm->cm_ops) {
240 ret = (*getops)(cm->cm_ops);
244 if (!cm->cm_ops->mo_init ||
245 !cm->cm_ops->mo_uninit ||
246 !cm->cm_ops->mo_convert ||
247 !cm->cm_ops->mo_init_state) {
253 cm->cm_traits = malloc(sizeof(*cm->cm_traits));
254 if (cm->cm_traits == NULL) {
259 ret = (*cm->cm_ops->mo_init)(ma, cm, ma->ma_dir,
261 cm->cm_traits, sizeof(*cm->cm_traits));
265 *rcm = cm;
270 mapper_close(cm);
301 match_func(struct _citrus_mapper *cm, const char *key)
304 return (strcmp(cm->cm_key, key));
316 struct _citrus_mapper *cm;
327 _CITRUS_HASH_SEARCH(&ma->ma_cache, cm, cm_entry, match_func, mapname,
329 if (cm) {
331 cm->cm_refcount++;
332 *rcm = cm;
345 ret = mapper_open(ma, &cm, module, variable);
349 cm->cm_key = strdup(mapname);
350 if (cm->cm_key == NULL) {
352 _mapper_close(cm);
357 cm->cm_refcount = 1;
358 _CITRUS_HASH_INSERT(&ma->ma_cache, cm, cm_entry, hashval);
360 *rcm = cm;
373 _citrus_mapper_close(struct _citrus_mapper *cm)
376 if (cm) {
378 if (cm->cm_refcount == REFCOUNT_PERSISTENT)
380 if (cm->cm_refcount > 0) {
381 if (--cm->cm_refcount > 0)
383 _CITRUS_HASH_REMOVE(cm, cm_entry);
384 free(cm->cm_key);
387 mapper_close(cm);
399 _citrus_mapper_set_persistent(struct _citrus_mapper * __restrict cm)
403 cm->cm_refcount = REFCOUNT_PERSISTENT;