summaryrefslogtreecommitdiff
path: root/libmu_sieve/mem.c
AgeCommit message (Collapse)AuthorFiles
2016-12-04sieve: redo symbol registry support.Sergey Poznyakoff1
The purpose is to simplify the machine structure and to ensure its clones are completely independent of the master instance. * include/mailutils/sieve.h (mu_sieve_command): New struct. (mu_sieve_record): New enum (mu_sieve_registry_t): Generalize for storing various types of objects. (mu_sieve_test_lookup,mu_sieve_action_lookup) (mu_sieve_require_action,mu_sieve_require_test) (mu_sieve_require_comparator): Remove. (mu_sieve_register_test_ext,mu_sieve_register_test) (mu_sieve_register_action_ext,mu_sieve_register_action) (mu_sieve_register_comparator) (mu_sieve_load_ext): Change return type. (mu_sieve_registry_require,mu_sieve_unload_ext): New functions. (mu_sieve_machine_inherit): Rename to mu_sieve_machine_clone. * libmu_sieve/sieve-priv.h (mu_sieve_machine): Remove source_list, test_list, action_list, and comp_list. Add a single registry list instead. Add space for file and command (action and test) names: idspace, idcount, idmax. Remove unused field "stack"; (mu_i_sv_lex_finish): Change prototype. (_mu_i_sv_instr_push,_mu_i_sv_instr_pop): Remove protos. (mu_i_sv_id_canon,mu_i_sv_id_num) (mu_i_sv_id_str,mu_i_sv_free_idspace): New protos. * libmu_sieve/register.c: Rename to registry.c * libmu_sieve/registry.c (mu_sieve_test_lookup) (mu_sieve_action_lookup): Remove. (mu_sieve_require_test,mu_sieve_require_action): Remove. (mu_sieve_registry_require): New function. (mu_sieve_registry_add,mu_sieve_registry_lookup): New functions. * libmu_sieve/Makefile.am: Update. * libmu_sieve/comparator.c: Rewrite using new registry functions. * libmu_sieve/load.c (mu_sieve_load_ext): Return module handle. (mu_sieve_unload_ext): New function. * libmu_sieve/mem.c (mu_sieve_free): Gracefully handle NULL argument. (mu_i_sv_id_canon,mu_i_sv_id_num,mu_i_sv_id_str): New functions. * libmu_sieve/prog.c (mu_i_sv_locus): Store index of the file name in the id space, instead of pointer to the name itself. * libmu_sieve/require.c (mu_sieve_require): Rewrite. * libmu_sieve/runtime.c (_mu_i_sv_instr_source): Expect ID index as argument. (_mu_i_sv_instr_push) (_mu_i_sv_instr_pop): Remove unused instructions. * libmu_sieve/sieve.l (file_names): Remove. Use mu_sieve_machine idspace instead. * libmu_sieve/sieve.y (mu_sieve_machine_clone) (mu_sieve_machine_dup): Rewrite. (mu_sieve_machine_destroy): Free idspace and registry * examples/numaddr.c: Reflect changes. * libmu_sieve/extensions/editheader.c: Likewise. * libmu_sieve/extensions/list.c: Likewise. * libmu_sieve/extensions/moderator.c: Likewise. * libmu_sieve/extensions/pipe.c: Likewise. * libmu_sieve/extensions/spamd.c: Likewise. * libmu_sieve/extensions/timestamp.c: Likewise. * libmu_sieve/extensions/vacation.c: Likewise.
2016-12-03CleanupSergey Poznyakoff1
* include/mailutils/sieve.h (SVT_IDENT): Remove. * libmu_sieve/comparator.c (mu_sieve_match_part_checker): Remove unused variable. * libmu_sieve/mem.c (mu_sieve_reclaim_list): Remove function. * libmu_sieve/sieve.y: Remove leftover uses of SVT_IDENT. * libmu_sieve/util.c: Likewise. * libmu_sieve/sieve-priv.h: Remove useless prototypes.
2016-12-02sieve: change string allocation and argument passing conventionSergey Poznyakoff1
Strings are allocated in a per-machine string space. String and argument lists form contiguous arrays of structures. Regular ex- pressions are compiled when they are needed. Compiled expressions are cached for eventual reuse.
2016-11-29sieve: improve memory allocationSergey Poznyakoff1
* include/mailutils/sieve.h (mu_sieve_alloc) (mu_sieve_palloc,mu_sieve_prealloc) (mu_sieve_pfree,mu_sieve_pstrdup): Remove. (mu_sieve_mstrdup,mu_sieve_mrealloc) (mu_sieve_mfree): Remove. (mu_sieve_reclaim_t): New typedef. (mu_sieve_calloc,mu_sieve_strdup) (mu_sieve_realloc) (mu_sieve_reclaim_default,mu_sieve_reclaim_list) (mu_sieve_reclaim_value,mu_sieve_reclaim_tag): New functions (mu_sieve_value_create): Change prototype (take mu_sieve_machine_t as first argument) * libmu_sieve/mem.c: New file. * libmu_sieve/Makefile.am: Add new file. * libmu_sieve/comparator.c: Use new allocation functions. * libmu_sieve/prog.c: Likewise. * libmu_sieve/register.c: Likewise. * libmu_sieve/sieve.l: Likewise. * libmu_sieve/sieve.y: Likewise. * libmu_sieve/util.c: Likewise. * doc/texinfo/libmu_sieve.texi: Update (needs revision).

Return to:

Send suggestions and report system problems to the System administrator.