/* 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:
*
*/
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';
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;
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,
{
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
}
/* 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; i<no; i++)
if (qa)
for (i=0; qa[i]; i++)
no++;
- ap = (struct ccl_rpn_attr **)malloc ((no ? (no+1) : 2) * sizeof(*ap));
+ ap = (struct ccl_rpn_attr **)xmalloc ((no ? (no+1) : 2) * sizeof(*ap));
ccl_assert (ap);
field_str = ccl_qual_search_special(cclp->bibset, "field");
if (!node_sub)
{
ccl_rpn_delete (node);
- free (ap);
+ xfree (ap);
return 0;
}
if (node)
{
cclp->look_token = lookahead;
cclp->error_code = CCL_ERR_UNKNOWN_QUAL;
- free (ap);
+ xfree (ap);
return NULL;
}
lookahead = lookahead->next;
{
cclp->look_token = lookahead;
cclp->error_code = CCL_ERR_UNKNOWN_QUAL;
- free (ap);
+ xfree (ap);
return NULL;
}
lookahead = lookahead->next;
seq++;
}
}
- free (ap);
+ xfree (ap);
return node;
}
/* 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:
*
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
/* 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:
*
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;
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';
;
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;
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++)
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;
else
{
if (q->sub)
- free (q->sub);
+ xfree (q->sub);
attrp = &q->attr_list;
while (*attrp)
attrp = &(*attrp)->next;
{
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++;
*/
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;
{
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;
}
/* 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:
*
}
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;
}
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;
while (list)
{
list1 = list->next;
- free (list);
+ xfree (list);
list = list1;
}
}
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;
{
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)
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);
}
}
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);
}
}
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);
}
}
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);
}
}