[SR-Dev] git:master: Remove function replace_len which is no longer needed.

Jan Janak jan at iptel.org
Sun Mar 8 04:43:57 CET 2009


Module: sip-router
Branch: master
Commit: 578b3a95ec13d1ca934c02fed8291aa5419f2160
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=578b3a95ec13d1ca934c02fed8291aa5419f2160

Author: Jan Janak <jan at iptel.org>
Committer: Jan Janak <jan at iptel.org>
Date:   Sun Mar  8 04:42:10 2009 +0100

Remove function replace_len which is no longer needed.

This function was originally used to calculate the size of the memory
buffer in replace_build for the resulting string. Since we now print
the result into a static buffer, this function is no longer needed.

---

 re.c |   46 ----------------------------------------------
 1 files changed, 0 insertions(+), 46 deletions(-)

diff --git a/re.c b/re.c
index 6b19786..2b2f6b0 100644
--- a/re.c
+++ b/re.c
@@ -328,52 +328,6 @@ error:
 	return 0;
 }
 
-
-
-static int replace_len(const char* match, int nmatch, regmatch_t* pmatch,
-					struct subst_expr* se, struct sip_msg* msg)
-{
-	int r;
-	int len;
-	str* uri;
-	
-	len=se->replacement.len;
-	for (r=0; r<se->n_escapes; r++){
-		switch(se->replace[r].type){
-			case REPLACE_NMATCH:
-				len-=se->replace[r].size;
-				if ((se->replace[r].u.nmatch<nmatch)&&(
-						pmatch[se->replace[r].u.nmatch].rm_so!=-1)){
-						/* do the replace */
-						len+=pmatch[se->replace[r].u.nmatch].rm_eo-
-								pmatch[se->replace[r].u.nmatch].rm_so;
-				};
-				break;
-			case REPLACE_CHAR:
-				len-=(se->replace[r].size-1);
-				break;
-			case REPLACE_URI:
-				len-=se->replace[r].size;
-				if (msg->first_line.type!=SIP_REQUEST){
-					LOG(L_CRIT, "BUG: replace_len: uri substitution on"
-								" a reply\n");
-					break; /* ignore, we can continue */
-				}
-				uri= (msg->new_uri.s)?(&msg->new_uri):
-					(&msg->first_line.u.request.uri);
-				len+=uri->len;
-				break;
-			default:
-				LOG(L_CRIT, "BUG: replace_len: unknown type %d\n", 
-						se->replace[r].type);
-				/* ignore it */
-		}
-	}
-	return len;
-}
-
-
-
 /* rpl.s will be alloc'ed with the proper size & rpl.len set
  * returns 0 on success, <0 on error*/
 static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,




More information about the sr-dev mailing list