Browse code

hooks parameter of parse_params() is made optional, it is not always needed

Miklos Tirpak authored on 22/05/2008 16:06:15
Showing 1 changed files
... ...
@@ -54,6 +54,10 @@ static inline void parse_contact_class(param_hooks_t* _h, param_t* _p)
54 54
 		LOG(L_ERR, "ERROR: parse_contact_class: empty value\n");
55 55
 		return;
56 56
 	}
57
+	if (!_h) {
58
+		LOG(L_CRIT, "BUG: parse_uri_class: NULL param hook pointer\n");
59
+		return;
60
+	}
57 61
 	switch(_p->name.s[0]) {
58 62
 	case 'q':
59 63
 	case 'Q':
... ...
@@ -111,6 +115,10 @@ static inline void parse_uri_class(param_hooks_t* _h, param_t* _p)
111 115
 		LOG(L_ERR, "ERROR: parse_uri_class: empty value\n");
112 116
 		return;
113 117
 	}
118
+	if (!_h) {
119
+		LOG(L_CRIT, "BUG: parse_uri_class: NULL param hook pointer\n");
120
+		return;
121
+	}
114 122
 	switch(_p->name.s[0]) {
115 123
 	case 't':
116 124
 	case 'T':
... ...
@@ -316,7 +324,7 @@ static inline void parse_param_name(str* _s, pclass_t _c, param_hooks_t* _h, par
316 324
 
317 325
  out:
318 326
 	_p->name.len = _s->s - _p->name.s;
319
-	
327
+
320 328
 	switch(_c) {
321 329
 	case CLASS_CONTACT: parse_contact_class(_h, _p); break;
322 330
 	case CLASS_URI:     parse_uri_class(_h, _p);     break;
... ...
@@ -436,12 +444,13 @@ int parse_params(str* _s, pclass_t _c, param_hooks_t* _h, param_t** _p)
436 444
 {
437 445
 	param_t* t;
438 446
 
439
-	if (!_s || !_h || !_p) {
447
+	if (!_s || !_p) {
440 448
 		LOG(L_ERR, "parse_params(): Invalid parameter value\n");
441 449
 		return -1;
442 450
 	}
443 451
 
444
-	memset(_h, 0, sizeof(param_hooks_t));
452
+	if (_h)
453
+		memset(_h, 0, sizeof(param_hooks_t));
445 454
 	*_p = 0;
446 455
 
447 456
 	if (!_s->s) { /* no parameters at all -- we're done */