From: Adam Dickmeiss Date: Thu, 6 Jun 2002 12:54:24 +0000 (+0000) Subject: Using xmalloc/xfree instead of malloc/free X-Git-Tag: YAZ.1.8.8~36 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=6f41c38bc479344d4ecd347a607546dc95971efa;p=yaz-moved-to-github.git Using xmalloc/xfree instead of malloc/free --- diff --git a/ccl/cclfind.c b/ccl/cclfind.c index 60a6577..388e7ba 100644 --- a/ccl/cclfind.c +++ b/ccl/cclfind.c @@ -44,7 +44,7 @@ /* CCL find (to rpn conversion) * Europagate, 1995 * - * $Id: cclfind.c,v 1.30 2002-05-17 08:46:01 adam Exp $ + * $Id: cclfind.c,v 1.31 2002-06-06 12:54:24 adam Exp $ * * Old Europagate log: * @@ -160,7 +160,7 @@ static void strxcat (char *n, const char *src, int len) */ static char *copy_token_name (struct ccl_token *tp) { - char *str = (char *)malloc (tp->len + 1); + char *str = (char *)xmalloc (tp->len + 1); ccl_assert (str); memcpy (str, tp->name, tp->len); str[tp->len] = '\0'; @@ -175,7 +175,7 @@ static char *copy_token_name (struct ccl_token *tp) static struct ccl_rpn_node *mk_node (int kind) { struct ccl_rpn_node *p; - p = (struct ccl_rpn_node *)malloc (sizeof(*p)); + p = (struct ccl_rpn_node *)xmalloc (sizeof(*p)); ccl_assert (p); p->kind = kind; return p; @@ -199,24 +199,24 @@ void ccl_rpn_delete (struct ccl_rpn_node *rpn) ccl_rpn_delete (rpn->u.p[1]); break; case CCL_RPN_TERM: - free (rpn->u.t.term); + xfree (rpn->u.t.term); for (attr = rpn->u.t.attr_list; attr; attr = attr1) { attr1 = attr->next; if (attr->set) - free (attr->set); - free (attr); + xfree (attr->set); + xfree (attr); } break; case CCL_RPN_SET: - free (rpn->u.setname); + xfree (rpn->u.setname); break; case CCL_RPN_PROX: ccl_rpn_delete (rpn->u.p[0]); ccl_rpn_delete (rpn->u.p[1]); break; } - free (rpn); + xfree (rpn); } static struct ccl_rpn_node *find_spec (CCL_parser cclp, @@ -245,11 +245,11 @@ static void add_attr (struct ccl_rpn_node *p, const char *set, { struct ccl_rpn_attr *n; - n = (struct ccl_rpn_attr *)malloc (sizeof(*n)); + n = (struct ccl_rpn_attr *)xmalloc (sizeof(*n)); ccl_assert (n); if (set) { - n->set = (char*) malloc (strlen(set)+1); + n->set = (char*) xmalloc (strlen(set)+1); strcpy (n->set, set); } else @@ -417,7 +417,7 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp, } /* make the RPN token */ - p->u.t.term = (char *)malloc (len); + p->u.t.term = (char *)xmalloc (len); ccl_assert (p->u.t.term); p->u.t.term[0] = '\0'; for (i = 0; ibibset, "field"); @@ -687,7 +687,7 @@ static struct ccl_rpn_node *qualifiers1 (CCL_parser cclp, struct ccl_token *la, if (!node_sub) { ccl_rpn_delete (node); - free (ap); + xfree (ap); return 0; } if (node) @@ -705,7 +705,7 @@ static struct ccl_rpn_node *qualifiers1 (CCL_parser cclp, struct ccl_token *la, { cclp->look_token = lookahead; cclp->error_code = CCL_ERR_UNKNOWN_QUAL; - free (ap); + xfree (ap); return NULL; } lookahead = lookahead->next; @@ -734,7 +734,7 @@ static struct ccl_rpn_node *qualifiers1 (CCL_parser cclp, struct ccl_token *la, { cclp->look_token = lookahead; cclp->error_code = CCL_ERR_UNKNOWN_QUAL; - free (ap); + xfree (ap); return NULL; } lookahead = lookahead->next; @@ -773,7 +773,7 @@ static struct ccl_rpn_node *qualifiers1 (CCL_parser cclp, struct ccl_token *la, seq++; } } - free (ap); + xfree (ap); return node; } diff --git a/ccl/cclqfile.c b/ccl/cclqfile.c index 230492b..b4aab41 100644 --- a/ccl/cclqfile.c +++ b/ccl/cclqfile.c @@ -44,7 +44,7 @@ /* CCL qualifiers * Europagate, 1995 * - * $Id: cclqfile.c,v 1.12 2001-11-27 22:38:50 adam Exp $ + * $Id: cclqfile.c,v 1.13 2002-06-06 12:54:24 adam Exp $ * * Old Europagate Log: * @@ -161,7 +161,7 @@ void ccl_qual_field (CCL_bibset bibset, const char *cp, const char *qual_name) pair[pair_no*2+1] = value; if (setp) { - attsets[pair_no] = (char*) malloc (strlen(qual_spec)+1); + attsets[pair_no] = (char*) xmalloc (strlen(qual_spec)+1); strcpy (attsets[pair_no], qual_spec); } else diff --git a/ccl/cclqual.c b/ccl/cclqual.c index 5dcbd72..3fbb6c3 100644 --- a/ccl/cclqual.c +++ b/ccl/cclqual.c @@ -44,7 +44,7 @@ /* CCL qualifiers * Europagate, 1995 * - * $Id: cclqual.c,v 1.16 2001-11-27 22:38:50 adam Exp $ + * $Id: cclqual.c,v 1.17 2002-06-06 12:54:24 adam Exp $ * * Old Europagate Log: * @@ -118,10 +118,10 @@ void ccl_qual_add_special (CCL_bibset bibset, const char *n, const char *v) for (p = bibset->special; p && strcmp(p->name, n); p = p->next) ; if (p) - free (p->value); + xfree (p->value); else { - p = (struct ccl_qualifier_special *) malloc (sizeof(*p)); + p = (struct ccl_qualifier_special *) xmalloc (sizeof(*p)); p->name = ccl_strdup (n); p->value = 0; p->next = bibset->special; @@ -132,7 +132,7 @@ void ccl_qual_add_special (CCL_bibset bibset, const char *n, const char *v) for (pe = v + strlen(v); pe != v; --pe) if (!strchr(" \n\r\t", pe[-1])) break; - p->value = (char*) malloc (pe - v + 1); + p->value = (char*) xmalloc (pe - v + 1); if (pe - v) memcpy (p->value, v, pe - v); p->value[pe - v] = '\0'; @@ -165,7 +165,7 @@ void ccl_qual_add_combi (CCL_bibset b, const char *n, const char *names) ; if (q) return ; - q = (struct ccl_qualifier *) malloc (sizeof(*q)); + q = (struct ccl_qualifier *) xmalloc (sizeof(*q)); q->name = ccl_strdup (n); q->attr_list = 0; q->next = b->list; @@ -175,7 +175,7 @@ void ccl_qual_add_combi (CCL_bibset b, const char *n, const char *names) for (i = 0; next_token(&cp, 0); i++) ; q->no_sub = i; - q->sub = (struct ccl_qualifier **) malloc (sizeof(*q->sub) * + q->sub = (struct ccl_qualifier **) xmalloc (sizeof(*q->sub) * (1+q->no_sub)); cp = names; for (i = 0; (len = next_token(&cp, &cp1)); i++) @@ -206,7 +206,7 @@ void ccl_qual_add_set (CCL_bibset b, const char *name, int no, int *pairs, if (!q) { struct ccl_qualifier *new_qual = - (struct ccl_qualifier *)malloc (sizeof(*new_qual)); + (struct ccl_qualifier *)xmalloc (sizeof(*new_qual)); ccl_assert (new_qual); new_qual->next = b->list; @@ -221,7 +221,7 @@ void ccl_qual_add_set (CCL_bibset b, const char *name, int no, int *pairs, else { if (q->sub) - free (q->sub); + xfree (q->sub); attrp = &q->attr_list; while (*attrp) attrp = &(*attrp)->next; @@ -230,7 +230,7 @@ void ccl_qual_add_set (CCL_bibset b, const char *name, int no, int *pairs, { struct ccl_rpn_attr *attr; - attr = (struct ccl_rpn_attr *)malloc (sizeof(*attr)); + attr = (struct ccl_rpn_attr *)xmalloc (sizeof(*attr)); ccl_assert (attr); attr->set = *attsets++; attr->type = *pairs++; @@ -247,7 +247,7 @@ void ccl_qual_add_set (CCL_bibset b, const char *name, int no, int *pairs, */ CCL_bibset ccl_qual_mk (void) { - CCL_bibset b = (CCL_bibset)malloc (sizeof(*b)); + CCL_bibset b = (CCL_bibset)xmalloc (sizeof(*b)); ccl_assert (b); b->list = NULL; b->special = NULL; @@ -273,23 +273,23 @@ void ccl_qual_rm (CCL_bibset *b) { attr1 = attr->next; if (attr->set) - free (attr->set); - free (attr); + xfree (attr->set); + xfree (attr); } q1 = q->next; - free (q->name); + xfree (q->name); if (q->sub) - free (q->sub); - free (q); + xfree (q->sub); + xfree (q); } for (sp = (*b)->special; sp; sp = sp1) { sp1 = sp->next; - free (sp->name); - free (sp->value); - free (sp); + xfree (sp->name); + xfree (sp->value); + xfree (sp); } - free (*b); + xfree (*b); *b = NULL; } diff --git a/ccl/ccltoken.c b/ccl/ccltoken.c index 12111b1..afbac9c 100644 --- a/ccl/ccltoken.c +++ b/ccl/ccltoken.c @@ -44,7 +44,7 @@ /* CCL - lexical analysis * Europagate, 1995 * - * $Id: ccltoken.c,v 1.18 2001-11-27 22:38:50 adam Exp $ + * $Id: ccltoken.c,v 1.19 2002-06-06 12:54:24 adam Exp $ * * Old Europagate Log: * @@ -149,13 +149,13 @@ struct ccl_token *ccl_token_simple (const char *command) } if (!first) { - first = last = (struct ccl_token *)malloc (sizeof (*first)); + first = last = (struct ccl_token *)xmalloc (sizeof (*first)); ccl_assert (first); last->prev = NULL; } else { - last->next = (struct ccl_token *)malloc (sizeof(*first)); + last->next = (struct ccl_token *)xmalloc (sizeof(*first)); ccl_assert (last->next); last->next->prev = last; last = last->next; @@ -213,13 +213,13 @@ struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command) } if (!first) { - first = last = (struct ccl_token *)malloc (sizeof (*first)); + first = last = (struct ccl_token *)xmalloc (sizeof (*first)); ccl_assert (first); last->prev = NULL; } else { - last->next = (struct ccl_token *)malloc (sizeof(*first)); + last->next = (struct ccl_token *)xmalloc (sizeof(*first)); ccl_assert (last->next); last->next->prev = last; last = last->next; @@ -337,7 +337,7 @@ void ccl_token_del (struct ccl_token *list) while (list) { list1 = list->next; - free (list); + xfree (list); list = list1; } } @@ -345,14 +345,14 @@ void ccl_token_del (struct ccl_token *list) char *ccl_strdup (const char *str) { int len = strlen(str); - char *p = (char*) malloc (len+1); + char *p = (char*) xmalloc (len+1); strcpy (p, str); return p; } CCL_parser ccl_parser_create (void) { - CCL_parser p = (CCL_parser)malloc (sizeof(*p)); + CCL_parser p = (CCL_parser)xmalloc (sizeof(*p)); if (!p) return p; p->look_token = NULL; @@ -373,11 +373,11 @@ void ccl_parser_destroy (CCL_parser p) { if (!p) return; - free (p->ccl_token_and); - free (p->ccl_token_or); - free (p->ccl_token_not); - free (p->ccl_token_set); - free (p); + xfree (p->ccl_token_and); + xfree (p->ccl_token_or); + xfree (p->ccl_token_not); + xfree (p->ccl_token_set); + xfree (p); } void ccl_parser_set_op_and (CCL_parser p, const char *op) @@ -385,7 +385,7 @@ void ccl_parser_set_op_and (CCL_parser p, const char *op) if (p && op) { if (p->ccl_token_and) - free (p->ccl_token_and); + xfree (p->ccl_token_and); p->ccl_token_and = ccl_strdup (op); } } @@ -395,7 +395,7 @@ void ccl_parser_set_op_or (CCL_parser p, const char *op) if (p && op) { if (p->ccl_token_or) - free (p->ccl_token_or); + xfree (p->ccl_token_or); p->ccl_token_or = ccl_strdup (op); } } @@ -404,7 +404,7 @@ void ccl_parser_set_op_not (CCL_parser p, const char *op) if (p && op) { if (p->ccl_token_not) - free (p->ccl_token_not); + xfree (p->ccl_token_not); p->ccl_token_not = ccl_strdup (op); } } @@ -413,7 +413,7 @@ void ccl_parser_set_op_set (CCL_parser p, const char *op) if (p && op) { if (p->ccl_token_set) - free (p->ccl_token_set); + xfree (p->ccl_token_set); p->ccl_token_set = ccl_strdup (op); } }