- Timestamp:
- Oct 23, 2009, 11:01:30 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 8590774
- Parents:
- 52761cc
- git-author:
- Karl Ramm <kcr@1ts.org> (09/30/09 10:12:27)
- git-committer:
- Karl Ramm <kcr@1ts.org> (10/23/09 23:01:30)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
filter.c
r8bce750 r23fddad 2 2 #include "owl.h" 3 3 4 int owl_filter_init_fromstring(owl_filter *f, const char *name, const char *string) 5 { 4 owl_filter *owl_filter_new_fromstring(const char *name, const char *string) 5 { 6 owl_filter *f; 6 7 char **argv; 7 int argc , out;8 9 argv =owl_parseline(string, &argc);10 out=owl_filter_init(f,name, argc, strs(argv));8 int argc; 9 10 argv = owl_parseline(string, &argc); 11 f = owl_filter_new(name, argc, strs(argv)); 11 12 owl_parsefree(argv, argc); 12 return(out); 13 } 14 15 int owl_filter_init(owl_filter *f, const char *name, int argc, const char *const *argv) 16 { 13 14 return f; 15 } 16 17 owl_filter *owl_filter_new(const char *name, int argc, const char *const *argv) 18 { 19 owl_filter *f; 20 21 f = owl_malloc(sizeof(owl_filter)); 22 17 23 f->name=owl_strdup(name); 18 24 f->fgcolor=OWL_COLOR_DEFAULT; … … 40 46 } 41 47 42 if(!(f->root = owl_filter_parse_expression(argc, argv, NULL))) 43 return(-1); 48 if (!(f->root = owl_filter_parse_expression(argc, argv, NULL))) { 49 owl_filter_delete(f); 50 return NULL; 51 } 44 52 45 53 /* Now check for recursion. */ 46 54 if (owl_filter_is_toodeep(f)) { 47 55 owl_function_error("Filter loop!"); 48 owl_filter_ free(f);49 return (-1);50 } 51 52 return (0);56 owl_filter_delete(f); 57 return NULL; 58 } 59 60 return f; 53 61 } 54 62 … … 255 263 } 256 264 257 void owl_filter_free(owl_filter *f) 258 { 259 if(f->root) { 265 void owl_filter_delete(owl_filter *f) 266 { 267 if (f == NULL) 268 return; 269 if (f->root) { 260 270 owl_filterelement_free(f->root); 261 271 owl_free(f->root); 262 272 } 263 if (f->name) owl_free(f->name); 264 } 273 if (f->name) 274 owl_free(f->name); 275 owl_free(f); 276 }
Note: See TracChangeset
for help on using the changeset viewer.