Browse code

core: whitespace identation fixes

Daniel-Constantin Mierla authored on 11/09/2012 10:45:25
Showing 1 changed files
... ...
@@ -492,27 +492,32 @@ qvalue_t get_ruri_q(void)
492 492
  */
493 493
 int rewrite_uri(struct sip_msg* _m, str* _s)
494 494
 {
495
-        char* buf;
495
+	char *buf = NULL;
496 496
 
497
-        buf = (char*)pkg_malloc(_s->len + 1);
498
-        if (!buf) {
499
-                LOG(L_ERR, "ERROR: rewrite_uri: No memory left\n");
500
-                return -1;
501
-        }
497
+	if(_m->new_uri.s==NULL || _m->new_uri.len<_s->len) {
498
+		buf = (char*)pkg_malloc(_s->len + 1);
499
+		if (!buf) {
500
+			LM_ERR("No memory left to rewrite r-uri\n");
501
+			return -1;
502
+		}
503
+	}
504
+	if(buf!=NULL) {
505
+		if(_m->new_uri.s)
506
+			pkg_free(_m->new_uri.s);
507
+	} else {
508
+		buf = _m->new_uri.s;
509
+	}
502 510
 
503
-        memcpy(buf, _s->s, _s->len);
504
-        buf[_s->len] = '\0';
511
+	memcpy(buf, _s->s, _s->len);
512
+	buf[_s->len] = '\0';
505 513
 
506
-        _m->parsed_uri_ok = 0;
507
-        if (_m->new_uri.s) {
508
-                pkg_free(_m->new_uri.s);
509
-        }
514
+	_m->parsed_uri_ok = 0;
510 515
 
511
-        _m->new_uri.s = buf;
512
-        _m->new_uri.len = _s->len;
513
-        /* mark ruri as new and available for forking */
514
-        ruri_mark_new();
516
+	_m->new_uri.s = buf;
517
+	_m->new_uri.len = _s->len;
518
+	/* mark ruri as new and available for forking */
519
+	ruri_mark_new();
515 520
 
516
-        return 1;
521
+	return 1;
517 522
 }
518 523