1 /* This file is part of Pazpar2.
2 Copyright (C) 2006-2010 Index Data
4 Pazpar2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <yaz/yaz-util.h>
29 #include "normalize_cache.h"
31 #include "pazpar2_config.h"
35 struct cached_item *next;
36 normalize_record_t nt;
39 struct normalize_cache_s {
40 struct cached_item *items;
44 normalize_cache_t normalize_cache_create(void)
46 NMEM nmem = nmem_create();
47 normalize_cache_t nc = nmem_malloc(nmem, sizeof(*nc));
53 normalize_record_t normalize_cache_get(normalize_cache_t nc,
54 struct conf_service *service,
57 normalize_record_t nt;
58 struct cached_item *ci = nc->items;
59 for (; ci; ci = ci->next)
60 if (!strcmp(spec, ci->spec))
63 nt = normalize_record_create(service, spec);
66 ci = nmem_malloc(nc->nmem, sizeof(*ci));
70 ci->spec = nmem_strdup(nc->nmem, spec);
75 void normalize_cache_destroy(normalize_cache_t nc)
79 struct cached_item *ci = nc->items;
80 for (; ci; ci = ci->next)
81 normalize_record_destroy(ci->nt);
82 nmem_destroy(nc->nmem);
89 * c-file-style: "Stroustrup"
90 * indent-tabs-mode: nil
92 * vim: shiftwidth=4 tabstop=8 expandtab