Imported Upstream version 2.7
[ossec-hids.git] / src / os_regex / os_match_free_pattern.c
1 /*   $OSSEC, os_match_free_pattern.c, v0.1, 2006/04/18, Daniel B. Cid$   */
2
3 /* Copyright (C) 2009 Trend Micro Inc.
4  * All right reserved.
5  *
6  * This program is a free software; you can redistribute it
7  * and/or modify it under the terms of the GNU General Public
8  * License (version 2) as published by the FSF - Free Software
9  * Foundation
10  */
11
12
13 #include <stdio.h>
14 #include <string.h>
15 #include <stdlib.h>
16
17 #include "os_regex.h"
18 #include "os_regex_internal.h"
19
20
21 /** int OSMatch_FreePattern(OSMatch *reg) v0.1
22  * Release all the memory created by the compilation/executation
23  * phases.
24  * Returns void.
25  */
26 void OSMatch_FreePattern(OSMatch *reg)
27 {
28     /* Freeing the patterns */
29     if(reg->patterns)
30     {
31         char **pattern = reg->patterns;
32         while(*pattern)
33         {
34             if(*pattern)
35                 free(*pattern);
36             pattern++;
37         }
38
39         free(reg->patterns);
40         free(reg->size);
41         free(reg->match_fp);
42
43         reg->patterns = NULL;
44         reg->size = NULL;
45         reg->match_fp = NULL;
46     }
47
48     return;
49 }
50
51
52 /* EOF */