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, ...@@ -50,7 +50,7 @@ sieve_register_comparator (sieve_machine_t mach,
50 return rc; 50 return rc;
51 } 51 }
52 52
53 rp = sieve_palloc (&mach->memory_pool, sizeof (*rp)); 53 rp = sieve_malloc (mach, sizeof (*rp));
54 rp->required = required; 54 rp->required = required;
55 rp->name = name; 55 rp->name = name;
56 rp->comp[MU_SIEVE_MATCH_IS] = is; 56 rp->comp[MU_SIEVE_MATCH_IS] = is;
...@@ -154,7 +154,7 @@ _regex_compile (void *item, void *data) ...@@ -154,7 +154,7 @@ _regex_compile (void *item, void *data)
154 { 154 {
155 struct regex_data *rd = data; 155 struct regex_data *rd = data;
156 int rc; 156 int rc;
157 regex_t *preg = sieve_palloc (&sieve_machine->memory_pool, sizeof (*preg)); 157 regex_t *preg = sieve_malloc (sieve_machine, sizeof (*preg));
158 158
159 rc = regcomp (preg, (char*)item, rd->flags); 159 rc = regcomp (preg, (char*)item, rd->flags);
160 if (rc) 160 if (rc)
...@@ -263,12 +263,11 @@ sieve_match_part_checker (const char *name, list_t tags, list_t args) ...@@ -263,12 +263,11 @@ sieve_match_part_checker (const char *name, list_t tags, list_t args)
263 263
264 if (comp) 264 if (comp)
265 { 265 {
266 sieve_pfree (&sieve_machine->memory_pool, comp->arg); 266 sieve_mfree (sieve_machine, comp->arg);
267 } 267 }
268 else 268 else
269 { 269 {
270 comp = sieve_palloc (&sieve_machine->memory_pool, 270 comp = sieve_malloc (sieve_machine, sizeof (*comp));
271 sizeof (*comp));
272 comp->tag = "comparator"; 271 comp->tag = "comparator";
273 list_append (tags, comp); 272 list_append (tags, comp);
274 } 273 }
......
...@@ -29,8 +29,7 @@ sieve_code (sieve_op_t *op) ...@@ -29,8 +29,7 @@ sieve_code (sieve_op_t *op)
29 if (sieve_machine->pc >= sieve_machine->progsize) 29 if (sieve_machine->pc >= sieve_machine->progsize)
30 { 30 {
31 size_t newsize = sieve_machine->progsize + SIEVE_CODE_INCR; 31 size_t newsize = sieve_machine->progsize + SIEVE_CODE_INCR;
32 sieve_op_t *newprog = sieve_prealloc (&sieve_machine->memory_pool, 32 sieve_op_t *newprog = sieve_mrealloc (sieve_machine, sieve_machine->prog,
33 sieve_machine->prog,
34 newsize * 33 newsize *
35 sizeof sieve_machine->prog[0]); 34 sizeof sieve_machine->prog[0]);
36 if (!newprog) 35 if (!newprog)
...@@ -198,8 +197,7 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) ...@@ -198,8 +197,7 @@ sieve_code_command (sieve_register_t *reg, list_t arglist)
198 else 197 else
199 tagrec.arg = NULL; 198 tagrec.arg = NULL;
200 199
201 tagptr = sieve_palloc (&sieve_machine->memory_pool, 200 tagptr = sieve_malloc (sieve_machine, sizeof (*tagptr));
202 sizeof (*tagptr));
203 *tagptr = tagrec; 201 *tagptr = tagrec;
204 list_append (tag_list, tagptr); 202 list_append (tag_list, tagptr);
205 203
...@@ -235,7 +233,7 @@ sieve_code_command (sieve_register_t *reg, list_t arglist) ...@@ -235,7 +233,7 @@ sieve_code_command (sieve_register_t *reg, list_t arglist)
235 233
236 list_create (&list); 234 list_create (&list);
237 list_append (list, val->v.string); 235 list_append (list, val->v.string);
238 sieve_pfree (&sieve_machine->memory_pool, val); 236 sieve_mfree (sieve_machine, val);
239 val = sieve_value_create (SVT_STRING_LIST, list); 237 val = sieve_value_create (SVT_STRING_LIST, list);
240 } 238 }
241 else 239 else
......
...@@ -444,7 +444,7 @@ number () ...@@ -444,7 +444,7 @@ number ()
444 int 444 int
445 string () 445 string ()
446 { 446 {
447 yylval.string = sieve_palloc (&sieve_machine->memory_pool, yyleng - 1); 447 yylval.string = sieve_malloc (sieve_machine, yyleng - 1);
448 memcpy (yylval.string, yytext + 1, yyleng - 2); 448 memcpy (yylval.string, yytext + 1, yyleng - 2);
449 yylval.string[yyleng - 2] = 0; 449 yylval.string[yyleng - 2] = 0;
450 return STRING; 450 return STRING;
...@@ -497,7 +497,7 @@ multiline_finish () ...@@ -497,7 +497,7 @@ multiline_finish ()
497 } 497 }
498 498
499 /* Copy the contents */ 499 /* Copy the contents */
500 yylval.string = sieve_palloc (&sieve_machine->memory_pool, length + 1); 500 yylval.string = sieve_malloc (sieve_machine, length + 1);
501 p = yylval.string; 501 p = yylval.string;
502 for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr)) 502 for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr))
503 { 503 {
......
...@@ -435,7 +435,7 @@ sieve_get_daemon_email (sieve_machine_t mach) ...@@ -435,7 +435,7 @@ sieve_get_daemon_email (sieve_machine_t mach)
435 const char *domain = NULL; 435 const char *domain = NULL;
436 436
437 mu_get_user_email_domain (&domain); 437 mu_get_user_email_domain (&domain);
438 mach->daemon_email = sieve_palloc (&mach->memory_pool, 438 mach->daemon_email = sieve_malloc (mach,
439 sizeof(MAILER_DAEMON_PFX) + 439 sizeof(MAILER_DAEMON_PFX) +
440 strlen (domain)); 440 strlen (domain));
441 sprintf (mach->daemon_email, "%s%s", MAILER_DAEMON_PFX, domain); 441 sprintf (mach->daemon_email, "%s%s", MAILER_DAEMON_PFX, domain);
...@@ -446,8 +446,8 @@ sieve_get_daemon_email (sieve_machine_t mach) ...@@ -446,8 +446,8 @@ sieve_get_daemon_email (sieve_machine_t mach)
446 void 446 void
447 sieve_set_daemon_email (sieve_machine_t mach, const char *email) 447 sieve_set_daemon_email (sieve_machine_t mach, const char *email)
448 { 448 {
449 sieve_pfree (&mach->memory_pool, (void *)mach->daemon_email); 449 sieve_mfree (mach, (void *)mach->daemon_email);
450 mach->daemon_email = sieve_pstrdup (&mach->memory_pool, email); 450 mach->daemon_email = sieve_mstrdup (mach, email);
451 } 451 }
452 452
453 struct sieve_destr_record 453 struct sieve_destr_record
...@@ -464,12 +464,12 @@ sieve_machine_add_destructor (sieve_machine_t mach, sieve_destructor_t destr, ...@@ -464,12 +464,12 @@ sieve_machine_add_destructor (sieve_machine_t mach, sieve_destructor_t destr,
464 464
465 if (!mach->destr_list && list_create (&mach->destr_list)) 465 if (!mach->destr_list && list_create (&mach->destr_list))
466 return 1; 466 return 1;
467 p = sieve_palloc (&mach->memory_pool, sizeof (*p)); 467 p = sieve_malloc (mach, sizeof (*p));
468 if (!p) 468 if (!p)
469 return 1; 469 return 1;
470 p->destr = destr; 470 p->destr = destr;
471 p->ptr = ptr; 471 p->ptr = ptr;
472 return list_append (mach->memory_pool, p); 472 return list_append (mach->destr_list, p);
473 } 473 }
474 474
475 static int 475 static int
...@@ -524,16 +524,18 @@ sieve_compile (sieve_machine_t mach, const char *name) ...@@ -524,16 +524,18 @@ sieve_compile (sieve_machine_t mach, const char *name)
524 524
525 if (sieve_lex_begin (name) == 0) 525 if (sieve_lex_begin (name) == 0)
526 { 526 {
527 sieve_machine->filename = sieve_pstrdup (&sieve_machine->memory_pool, 527 sieve_machine->filename = sieve_mstrdup (sieve_machine, name);
528 name);
529 rc = yyparse (); 528 rc = yyparse ();
529 if (sieve_error_count)
530 rc = 1;
530 sieve_lex_finish (); 531 sieve_lex_finish ();
531 } 532 }
532 else 533 else
533 rc = 1; 534 rc = 1;
535
534 sieve_machine_finish (mach); 536 sieve_machine_finish (mach);
535 if (sieve_error_count) 537 if (rc)
536 rc = 1; 538 sieve_machine_destroy (&mach);
537 return rc; 539 return rc;
538 } 540 }
539 541
......