Commit 6e26d7b6 6e26d7b6efb362188f693690949f099c43241ab7 by Sergey Poznyakoff

Use sieve_m.* memory allocation functions.

1 parent 35ddbb9e
......@@ -50,7 +50,7 @@ sieve_register_comparator (sieve_machine_t mach,
return rc;
}
rp = sieve_palloc (&mach->memory_pool, sizeof (*rp));
rp = sieve_malloc (mach, sizeof (*rp));
rp->required = required;
rp->name = name;
rp->comp[MU_SIEVE_MATCH_IS] = is;
......@@ -154,7 +154,7 @@ _regex_compile (void *item, void *data)
{
struct regex_data *rd = data;
int rc;
regex_t *preg = sieve_palloc (&sieve_machine->memory_pool, sizeof (*preg));
regex_t *preg = sieve_malloc (sieve_machine, sizeof (*preg));
rc = regcomp (preg, (char*)item, rd->flags);
if (rc)
......@@ -263,12 +263,11 @@ sieve_match_part_checker (const char *name, list_t tags, list_t args)
if (comp)
{
sieve_pfree (&sieve_machine->memory_pool, comp->arg);
sieve_mfree (sieve_machine, comp->arg);
}
else
{
comp = sieve_palloc (&sieve_machine->memory_pool,
sizeof (*comp));
comp = sieve_malloc (sieve_machine, sizeof (*comp));
comp->tag = "comparator";
list_append (tags, comp);
}
......
......@@ -29,8 +29,7 @@ sieve_code (sieve_op_t *op)
if (sieve_machine->pc >= sieve_machine->progsize)
{
size_t newsize = sieve_machine->progsize + SIEVE_CODE_INCR;
sieve_op_t *newprog = sieve_prealloc (&sieve_machine->memory_pool,
sieve_machine->prog,
sieve_op_t *newprog = sieve_mrealloc (sieve_machine, sieve_machine->prog,
newsize *
sizeof sieve_machine->prog[0]);
if (!newprog)
......@@ -198,8 +197,7 @@ sieve_code_command (sieve_register_t *reg, list_t arglist)
else
tagrec.arg = NULL;
tagptr = sieve_palloc (&sieve_machine->memory_pool,
sizeof (*tagptr));
tagptr = sieve_malloc (sieve_machine, sizeof (*tagptr));
*tagptr = tagrec;
list_append (tag_list, tagptr);
......@@ -235,7 +233,7 @@ sieve_code_command (sieve_register_t *reg, list_t arglist)
list_create (&list);
list_append (list, val->v.string);
sieve_pfree (&sieve_machine->memory_pool, val);
sieve_mfree (sieve_machine, val);
val = sieve_value_create (SVT_STRING_LIST, list);
}
else
......
......@@ -444,7 +444,7 @@ number ()
int
string ()
{
yylval.string = sieve_palloc (&sieve_machine->memory_pool, yyleng - 1);
yylval.string = sieve_malloc (sieve_machine, yyleng - 1);
memcpy (yylval.string, yytext + 1, yyleng - 2);
yylval.string[yyleng - 2] = 0;
return STRING;
......@@ -497,7 +497,7 @@ multiline_finish ()
}
/* Copy the contents */
yylval.string = sieve_palloc (&sieve_machine->memory_pool, length + 1);
yylval.string = sieve_malloc (sieve_machine, length + 1);
p = yylval.string;
for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr))
{
......
......@@ -435,7 +435,7 @@ sieve_get_daemon_email (sieve_machine_t mach)
const char *domain = NULL;
mu_get_user_email_domain (&domain);
mach->daemon_email = sieve_palloc (&mach->memory_pool,
mach->daemon_email = sieve_malloc (mach,
sizeof(MAILER_DAEMON_PFX) +
strlen (domain));
sprintf (mach->daemon_email, "%s%s", MAILER_DAEMON_PFX, domain);
......@@ -446,8 +446,8 @@ sieve_get_daemon_email (sieve_machine_t mach)
void
sieve_set_daemon_email (sieve_machine_t mach, const char *email)
{
sieve_pfree (&mach->memory_pool, (void *)mach->daemon_email);
mach->daemon_email = sieve_pstrdup (&mach->memory_pool, email);
sieve_mfree (mach, (void *)mach->daemon_email);
mach->daemon_email = sieve_mstrdup (mach, email);
}
struct sieve_destr_record
......@@ -464,12 +464,12 @@ sieve_machine_add_destructor (sieve_machine_t mach, sieve_destructor_t destr,
if (!mach->destr_list && list_create (&mach->destr_list))
return 1;
p = sieve_palloc (&mach->memory_pool, sizeof (*p));
p = sieve_malloc (mach, sizeof (*p));
if (!p)
return 1;
p->destr = destr;
p->ptr = ptr;
return list_append (mach->memory_pool, p);
return list_append (mach->destr_list, p);
}
static int
......@@ -524,16 +524,18 @@ sieve_compile (sieve_machine_t mach, const char *name)
if (sieve_lex_begin (name) == 0)
{
sieve_machine->filename = sieve_pstrdup (&sieve_machine->memory_pool,
name);
sieve_machine->filename = sieve_mstrdup (sieve_machine, name);
rc = yyparse ();
if (sieve_error_count)
rc = 1;
sieve_lex_finish ();
}
else
rc = 1;
sieve_machine_finish (mach);
if (sieve_error_count)
rc = 1;
if (rc)
sieve_machine_destroy (&mach);
return rc;
}
......