X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffacet_limit.c;h=405dfcdb2323b5c15322529eba467271491332cd;hb=64dccf5757a22cedd3c21ca834e3e02f39dd0504;hp=dca5c2985ebb60e7136f128f583c9c6a548dcaf1;hpb=58aba67e02b51934a2cae721269fb381d8b0b08b;p=pazpar2-moved-to-github.git diff --git a/src/facet_limit.c b/src/facet_limit.c index dca5c29..405dfcd 100644 --- a/src/facet_limit.c +++ b/src/facet_limit.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2011 Index Data + Copyright (C) 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 @@ -39,6 +39,28 @@ struct facet_limits { char **darray; }; +facet_limits_t facet_limits_dup(facet_limits_t fl) +{ + int i; + NMEM nmem = nmem_create(); + facet_limits_t fn = nmem_malloc(nmem, sizeof(*fn)); + fn->nmem = nmem; + fn->num = fl->num; + fn->darray = 0; + if (fl->num) + { + fn->darray = nmem_malloc(nmem, fn->num * sizeof(*fn->darray)); + for (i = 0; i < fn->num; i++) + { + const char *src = fl->darray[i]; + size_t sz = strlen(src) + 2 + strlen(src + strlen(src) + 1); + fn->darray[i] = nmem_malloc(nmem, sz); + memcpy(fn->darray[i], src, sz); + } + } + return fn; +} + facet_limits_t facet_limits_create(const char *param) { int i; @@ -48,8 +70,8 @@ facet_limits_t facet_limits_create(const char *param) fl->num = 0; fl->darray = 0; if (param) - nmem_strsplit_escape(fl->nmem, ",", param, &fl->darray, - &fl->num, 1, '\\'); + nmem_strsplit_escape2(fl->nmem, ",", param, &fl->darray, + &fl->num, 1, '\\', 0); /* replace = with \0 .. for each item */ for (i = 0; i < fl->num; i++) {