/* This file is part of Pazpar2.
- Copyright (C) 2006-2008 Index Data
+ Copyright (C) 2006-2009 Index Data
Pazpar2 is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
struct pp2_charset_s {
const char *(*token_next_handler)(pp2_relevance_token_t prt);
const char *(*get_sort_handler)(pp2_relevance_token_t prt, int skip);
+ int ref_count;
#if YAZ_HAVE_ICU
struct icu_chain * icu_chn;
UErrorCode icu_sts;
#endif // YAZ_HAVE_ICU
}
+void pp2_charset_incref(pp2_charset_t pct)
+{
+ (pct->ref_count)++;
+}
pp2_charset_t pp2_charset_create(struct icu_chain * icu_chn)
{
pct->token_next_handler = pp2_relevance_token_a_to_z;
pct->get_sort_handler = pp2_get_sort_ascii;
+ pct->ref_count = 1;
#if YAZ_HAVE_ICU
pct->icu_chn = 0;
if (icu_chn)
void pp2_charset_destroy(pp2_charset_t pct)
{
- xfree(pct);
+ if (pct)
+ {
+ assert(pct->ref_count >= 1);
+ --(pct->ref_count);
+ if (pct->ref_count == 0)
+ {
+#if YAZ_HAVE_ICU
+ icu_chain_destroy(pct->icu_chn);
+#endif
+ xfree(pct);
+ }
+ }
}
pp2_relevance_token_t pp2_relevance_tokenize(pp2_charset_t pct,
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
*/
+