new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / os_regex / os_match_free_pattern.c
1 /* Copyright (C) 2009 Trend Micro Inc.
2  * All right reserved.
3  *
4  * This program is a free software; you can redistribute it
5  * and/or modify it under the terms of the GNU General Public
6  * License (version 2) as published by the FSF - Free Software
7  * Foundation
8  */
9
10 #include <stdio.h>
11 #include <string.h>
12 #include <stdlib.h>
13
14 #include "os_regex.h"
15 #include "os_regex_internal.h"
16
17
18 /* Release all the memory created by the compilation/execution phases */
19 void OSMatch_FreePattern(OSMatch *reg)
20 {
21     /* Free the match data */
22     if (reg->match_data) {
23         pcre2_match_data_free(reg->match_data);
24         reg->match_data = NULL;
25     }
26
27     /* Free the regex */
28     if (reg->regex) {
29         pcre2_code_free(reg->regex);
30         reg->regex = NULL;
31     }
32
33     /* Free the patter, */
34     if (reg->pattern) {
35         free(reg->pattern);
36         reg->pattern = NULL;
37     }
38
39     return;
40 }
41