Browse code

- replaced all mallocs/frees with pkg_malloc/pkg_free

Andrei Pelinescu-Onciul authored on 19/03/2003 18:40:09
Showing 13 changed files
... ...
@@ -31,6 +31,7 @@
31 31
  * 2003-02-26: checks and group moved to separate modules (janakj)
32 32
  * 2003-03-10: New module interface (janakj)
33 33
  * 2003-03-16: flags export parameter added (janakj)
34
+ * 2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
34 35
  */
35 36
 
36 37
 #include <stdio.h>
... ...
@@ -197,7 +198,7 @@ static int challenge_fixup(void** param, int param_no)
197 198
 		qop = str2s(*param, strlen(*param), &err);
198 199
 		
199 200
 		if (err == 0) {
200
-			free(*param);
201
+			pkg_free(*param);
201 202
 			*param=(void*)qop;
202 203
 		} else {
203 204
 			LOG(L_ERR, "challenge_fixup(): Bad number <%s>\n",
... ...
@@ -218,7 +219,7 @@ static int str_fixup(void** param, int param_no)
218 219
 	str* s;
219 220
 	
220 221
 	if (param_no == 1) {
221
-		s = (str*)malloc(sizeof(str));
222
+		s = (str*)pkg_malloc(sizeof(str));
222 223
 		if (!s) {
223 224
 			LOG(L_ERR, "str_fixup(): No memory left\n");
224 225
 			return E_UNSPEC;
... ...
@@ -31,6 +31,7 @@
31 31
  * 2003-02-26: checks and group moved to separate modules (janakj)
32 32
  * 2003-03-11: New module interface (janakj)
33 33
  * 2003-03-16: flags export parameter added (janakj)
34
+ * 2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
34 35
  */
35 36
 
36 37
 #include <stdio.h>
... ...
@@ -39,6 +40,7 @@
39 40
 #include "../../db/db.h"
40 41
 #include "../../dprint.h"
41 42
 #include "../../error.h"
43
+#include "../../mem/mem.h"
42 44
 #include "authorize.h"
43 45
 #include "../auth/api.h"
44 46
 
... ...
@@ -183,7 +185,7 @@ static int str_fixup(void** param, int param_no)
183 185
 	str* s;
184 186
 
185 187
 	if (param_no == 1) {
186
-		s = (str*)malloc(sizeof(str));
188
+		s = (str*)pkg_malloc(sizeof(str));
187 189
 		if (!s) {
188 190
 			LOG(L_ERR, "str_fixup(): No memory left\n");
189 191
 			return E_UNSPEC;
... ...
@@ -28,9 +28,10 @@
28 28
  *
29 29
  * History:
30 30
  * -------
31
- * 2003-03-09: Based on auth_mod.c from radius_auth (janakj)
32
- * 2003-03-11: New module interface (janakj)
33
- * 2003-03-16: flags export parameter added (janakj)
31
+ *  2003-03-09: Based on auth_mod.c from radius_auth (janakj)
32
+ *  2003-03-11: New module interface (janakj)
33
+ *  2003-03-16: flags export parameter added (janakj)
34
+ *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
34 35
  */
35 36
 
36 37
 
... ...
@@ -41,6 +42,7 @@
41 42
 #include "../../sr_module.h"
42 43
 #include "../../error.h"
43 44
 #include "../../dprint.h"
45
+#include "../../mem/mem.h"
44 46
 #include "authrad_mod.h"
45 47
 #include "authorize.h"
46 48
 
... ...
@@ -128,7 +130,7 @@ static int str_fixup(void** param, int param_no)
128 130
 	str* s;
129 131
 
130 132
 	if (param_no == 1) {
131
-		s = (str*)malloc(sizeof(str));
133
+		s = (str*)pkg_malloc(sizeof(str));
132 134
 		if (!s) {
133 135
 			LOG(L_ERR, "auth_radius: str_fixup(): No memory left\n");
134 136
 			return E_UNSPEC;
... ...
@@ -24,9 +24,14 @@
24 24
  * along with this program; if not, write to the Free Software
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  */
27
+/* History:
28
+ * --------
29
+ *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
30
+ */
27 31
 
28 32
 #include <stdlib.h>
29 33
 #include <string.h>
34
+#include "../../mem/mem.h"
30 35
 #include "sub_list.h"
31 36
 
32 37
 struct node*   append_to_list(struct node *head, unsigned char *offset,
... ...
@@ -35,7 +40,7 @@ struct node*   append_to_list(struct node *head, unsigned char *offset,
35 40
 	struct node *n;
36 41
 	struct node *new_node;
37 42
 
38
-	new_node = malloc(sizeof(struct node));
43
+	new_node = pkg_malloc(sizeof(struct node));
39 44
 	if (!new_node)
40 45
 		return 0;
41 46
 	new_node->offset = offset;
... ...
@@ -76,7 +81,7 @@ void delete_list(struct node* head)
76 81
 ;
77 82
 	while (head) {
78 83
 		n=head->next;
79
-		free(head);
84
+		pkg_free(head);
80 85
 		head = n;
81 86
 	}
82 87
 }
... ...
@@ -28,9 +28,10 @@
28 28
  *
29 29
  * history
30 30
  * -------
31
- * 2003-02-28 scratchapd compatibility abandoned
32
- * 2003-01-29 scratchpad removed
33
- * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
31
+ *  2003-02-28 scratchapd compatibility abandoned
32
+ *  2003-01-29 scratchpad removed
33
+ *  2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
34
+ *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
34 35
  */
35 36
 
36 37
 /* functions for creating environment variables out of a request's
... ...
@@ -209,7 +210,7 @@ static int print_av_var(struct hf_wrapper *w)
209 210
 	char *c;
210 211
 
211 212
 	env_len=w->u.av.attr.len+1/*assignment*/+w->u.av.val.len+1/*ZT*/;
212
-	env=malloc(env_len);
213
+	env=pkg_malloc(env_len);
213 214
 	if (!env) {
214 215
 		LOG(L_ERR, "ERROR: print_av_var: no malloc mem\n");
215 216
 		return 0;
... ...
@@ -255,7 +256,7 @@ static int print_hf_var(struct hf_wrapper *w, int offset)
255 256
 	for(wi=w->next_same; wi; wi=wi->next_same) { /* other values, separated */
256 257
 		envvar_len+=1 /* separator */ + wi->u.hf->body.len;
257 258
 	}
258
-	envvar=malloc(w->prefix_len+hlen+1/*assignment*/+envvar_len+1/*ZT*/);
259
+	envvar=pkg_malloc(w->prefix_len+hlen+1/*assignment*/+envvar_len+1/*ZT*/);
259 260
 	if (!envvar) {
260 261
 		LOG(L_ERR, "ERROR: print_var: no envvar mem\n");
261 262
 		goto error00;
... ...
@@ -300,7 +301,7 @@ static void release_vars(struct hf_wrapper *list)
300 301
 {
301 302
 	while(list) {
302 303
 		if (list->envvar) {
303
-			free(list->envvar);
304
+			pkg_free(list->envvar);
304 305
 			list->envvar=0;
305 306
 		}
306 307
 		list=list->next_other;
... ...
@@ -368,7 +369,7 @@ environment_t *replace_env(struct hf_wrapper *list)
368 369
 	backup_env->old_cnt=var_cnt;
369 370
 	/* count length of our extensions */
370 371
 	for(w=list;w;w=w->next_other) var_cnt++;
371
-	new_env=malloc((var_cnt+1)*sizeof(char *));
372
+	new_env=pkg_malloc((var_cnt+1)*sizeof(char *));
372 373
 	if (!new_env) {
373 374
 		LOG(L_ERR, "ERROR: replace_env: no mem\n");
374 375
 		return 0;
... ...
@@ -404,12 +405,12 @@ void unset_env(environment_t *backup_env)
404 405
 	while(*cur_env) {
405 406
 		/* leave previously existing vars alone */
406 407
 		if (i>=backup_env->old_cnt) {
407
-			free(*cur_env);
408
+			pkg_free(*cur_env);
408 409
 		}
409 410
 		cur_env++;
410 411
 		i++;
411 412
 	}
412
-	free(cur_env0);
413
+	pkg_free(cur_env0);
413 414
 	pkg_free(backup_env);
414 415
 }
415 416
 
... ...
@@ -28,9 +28,10 @@
28 28
  *
29 29
  * History:
30 30
  * --------
31
- * 2003-02-25 - created by janakj
32
- * 2003-03-11 - New module interface (janakj)
33
- * 2003-03-16 - flags export parameter added (janakj)
31
+ *  2003-02-25 - created by janakj
32
+ *  2003-03-11 - New module interface (janakj)
33
+ *  2003-03-16 - flags export parameter added (janakj)
34
+ *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free
34 35
  */
35 36
 
36 37
 
... ...
@@ -186,9 +187,9 @@ static int hf_fixup(void** param, int param_no)
186 187
 			return E_UNSPEC;
187 188
 		}
188 189
 
189
-		free(ptr);
190
+		pkg_free(ptr);
190 191
 	} else if (param_no == 2) {
191
-		s = (str*)malloc(sizeof(str));
192
+		s = (str*)pkg_malloc(sizeof(str));
192 193
 		if (!s) {
193 194
 			LOG(L_ERR, "hf_fixup(): No memory left\n");
194 195
 			return E_UNSPEC;
... ...
@@ -28,8 +28,9 @@
28 28
  *
29 29
  * History:
30 30
  * --------
31
- * 2003-02-25 - created by janakj
32
- * 2003-03-16 - flags export parameter added (janakj)
31
+ *  2003-02-25 - created by janakj
32
+ *  2003-03-16 - flags export parameter added (janakj)
33
+ *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free
33 34
  */
34 35
 
35 36
 #include <string.h>
... ...
@@ -38,6 +39,7 @@
38 39
 #include "../../error.h"
39 40
 #include "../../dprint.h"
40 41
 #include "../../sr_module.h"
42
+#include "../../mem/mem.h"
41 43
 #include "grouprad_mod.h"
42 44
 #include "group.h"
43 45
 
... ...
@@ -132,9 +134,9 @@ static int hf_fixup(void** param, int param_no)
132 134
 			return E_UNSPEC;
133 135
 		}
134 136
 
135
-		free(ptr);
137
+		pkg_free(ptr);
136 138
 	} else if (param_no == 2) {
137
-		s = (str*)malloc(sizeof(str));
139
+		s = (str*)pkg_malloc(sizeof(str));
138 140
 		if (!s) {
139 141
 			LOG(L_ERR, "hf_fixup(): No memory left\n");
140 142
 			return E_UNSPEC;
... ...
@@ -32,6 +32,7 @@
32 32
  * --------
33 33
  *  2003-03-11  updated to the new module interface (andrei)
34 34
  *  2003-03-16  flags export parameter added (janakj)
35
+ *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
35 36
  */
36 37
 
37 38
 
... ...
@@ -43,6 +44,7 @@
43 44
 #include "../../dprint.h"
44 45
 #include "../../error.h"
45 46
 #include "../../ut.h"
47
+#include "../../mem/mem.h"
46 48
 #include "mf_funcs.h"
47 49
 
48 50
 
... ...
@@ -97,7 +99,7 @@ static int fixup_maxfwd_header(void** param, int param_no)
97 99
 					"number to big <%d> (max=255)\n",code);
98 100
 				return E_UNSPEC;
99 101
 			}
100
-			free(*param);
102
+			pkg_free(*param);
101 103
 			*param=(void*)code;
102 104
 			return 0;
103 105
 		}else{
... ...
@@ -30,6 +30,7 @@
30 30
  * --------
31 31
  *  2003-03-11  updated to the new module interface (andrei)
32 32
  *  2003-03-16  flags export parameter added (janakj)
33
+ *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
33 34
  */
34 35
 
35 36
 
... ...
@@ -38,6 +39,7 @@
38 39
 #include "../../sr_module.h"
39 40
 #include "../../ut.h"
40 41
 #include "../../error.h"
42
+#include "../../mem/mem.h"
41 43
 #include "strict.h"
42 44
 #include "loose.h"
43 45
 #include "common.h"
... ...
@@ -118,7 +120,7 @@ static int int_fixup(void** param, int param_no)
118 120
 		qop = str2s(*param, strlen(*param), &err);
119 121
 
120 122
 		if (err == 0) {
121
-			free(*param);
123
+			pkg_free(*param);
122 124
 			*param=(void*)qop;
123 125
 		} else {
124 126
 			LOG(L_ERR, "int_fixup(): Bad number <%s>\n",
... ...
@@ -52,6 +52,7 @@
52 52
  * --------
53 53
  *  2003-03-11  updated to the new module exports interface (andrei)
54 54
  *  2003-03-16  flags export parameter added (janakj)
55
+ *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free
55 56
  */
56 57
 
57 58
 
... ...
@@ -64,6 +65,7 @@
64 65
 #include "../../error.h"
65 66
 #include "../../ut.h"
66 67
 #include "../../script_cb.h"
68
+#include "../../mem/mem.h"
67 69
 #include "sl_stats.h"
68 70
 #include "sl_funcs.h"
69 71
 
... ...
@@ -135,7 +137,7 @@ static int fixup_sl_send_reply(void** param, int param_no)
135 137
 	if (param_no==1){
136 138
 		code=str2s(*param, strlen(*param), &err);
137 139
 		if (err==0){
138
-			free(*param);
140
+			pkg_free(*param);
139 141
 			*param=(void*)code;
140 142
 			return 0;
141 143
 		}else{
... ...
@@ -28,8 +28,9 @@
28 28
 /*
29 29
  * History:
30 30
  * --------
31
- *  2003-03-11 updated to the new module exports interface (andrei)
32
- *  2003-03-16 flags export parameter added (janakj)
31
+ *  2003-03-11  updated to the new module exports interface (andrei)
32
+ *  2003-03-16  flags export parameter added (janakj)
33
+ *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
33 34
  */
34 35
 
35 36
 
... ...
@@ -129,7 +130,7 @@ static int fixup_sms_send_msg_to_net(void** param, int param_no)
129 130
 				" not found in net list!\n",(char*)*param);
130 131
 			return E_UNSPEC;
131 132
 		} else {
132
-			free(*param);
133
+			pkg_free(*param);
133 134
 			*param=(void*)net_nr;
134 135
 			return 0;
135 136
 		}
... ...
@@ -35,16 +35,17 @@
35 35
  *
36 36
  * History:
37 37
  * -------
38
- * 2003-02-28  scratchpad compatibility abandoned (jiri)
39
- * 2003-01-29: - rewriting actions (replace, search_append) now begin
40
- *               at the second line -- previously, they could affect
41
- *               first line too, which resulted in wrong calculation of
42
- *               forwarded requests and an error consequently
43
- *             - replace_all introduced
44
- * 2003-01-28  scratchpad removed (jiri)
45
- * 2003-01-18  append_urihf introduced (jiri)
46
- * 2003-03-10  module export interface updated to the new format (andrei)
47
- * 2003-03-16  flags export parameter added (janakj)
38
+ *  2003-02-28  scratchpad compatibility abandoned (jiri)
39
+ *  2003-01-29: - rewriting actions (replace, search_append) now begin
40
+ *                at the second line -- previously, they could affect
41
+ *                first line too, which resulted in wrong calculation of
42
+ *                forwarded requests and an error consequently
43
+ *              - replace_all introduced
44
+ *  2003-01-28  scratchpad removed (jiri)
45
+ *  2003-01-18  append_urihf introduced (jiri)
46
+ *  2003-03-10  module export interface updated to the new format (andrei)
47
+ *  2003-03-16  flags export parameter added (janakj)
48
+ *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
48 49
  */
49 50
 
50 51
 
... ...
@@ -251,14 +252,14 @@ static int fixup_regex(void** param, int param_no)
251 252
 
252 253
 	DBG("module - fixing %s\n", (char*)(*param));
253 254
 	if (param_no!=1) return 0;
254
-	if ((re=malloc(sizeof(regex_t)))==0) return E_OUT_OF_MEM;
255
+	if ((re=pkg_malloc(sizeof(regex_t)))==0) return E_OUT_OF_MEM;
255 256
 	if (regcomp(re, *param, REG_EXTENDED|REG_ICASE|REG_NEWLINE) ){
256
-		free(re);
257
+		pkg_free(re);
257 258
 		LOG(L_ERR, "ERROR: %s : bad re %s\n", exports.name, (char*)*param);
258 259
 		return E_BAD_RE;
259 260
 	}
260 261
 	/* free string */
261
-	free(*param);
262
+	pkg_free(*param);
262 263
 	/* replace it with the compiled re */
263 264
 	*param=re;
264 265
 	return 0;
... ...
@@ -342,7 +343,7 @@ static int str_fixup(void** param, int param_no)
342 343
 {
343 344
 	str* s;
344 345
 
345
-	s = (str*)malloc(sizeof(str));
346
+	s = (str*)pkg_malloc(sizeof(str));
346 347
 	if (!s) {
347 348
 		LOG(L_ERR, "str_fixup(): No memory left\n");
348 349
 		return E_UNSPEC;
... ...
@@ -28,8 +28,9 @@
28 28
  *
29 29
  * History:
30 30
  * -------
31
- * 2003-03-11: New module interface (janakj)
32
- * 2003-03-16: flags export parameter added (janakj)
31
+ *  2003-03-11: New module interface (janakj)
32
+ *  2003-03-16: flags export parameter added (janakj)
33
+ *  2003-03-19  replaces all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
33 34
  */
34 35
 
35 36
 
... ...
@@ -159,7 +160,7 @@ static int str_fixup(void** param, int param_no)
159 160
 	str* s;
160 161
 	
161 162
 	if (param_no == 1) {
162
-		s = (str*)malloc(sizeof(str));
163
+		s = (str*)pkg_malloc(sizeof(str));
163 164
 		if (!s) {
164 165
 			LOG(L_ERR, "str_fixup(): No memory left\n");
165 166
 			return E_UNSPEC;