[SR-Dev] git:andrei/switch: rvalues: fix rval_new( empty string )
Andrei Pelinescu-Onciul
andrei at iptel.org
Thu Feb 19 23:50:55 CET 2009
Module: sip-router
Branch: andrei/switch
Commit: 5b37abcf81bade64b5bb8bc07ad4352e96c9d7b6
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5b37abcf81bade64b5bb8bc07ad4352e96c9d7b6
Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date: Thu Feb 19 21:51:43 2009 +0100
rvalues: fix rval_new( empty string )
- rval_new(RV_STR, empty string, ...) did not set properly the
string pointer
---
rvalue.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/rvalue.c b/rvalue.c
index 4c7472d..8bd0aa2 100644
--- a/rvalue.c
+++ b/rvalue.c
@@ -233,13 +233,17 @@ struct rvalue* rval_new(enum rval_type t, union rval_val* v, int extra_size)
{
struct rvalue* rv;
- if (t==RV_STR && v && v->s.len)
+ if (t==RV_STR && v && v->s.s)
return rval_new_str(&v->s, extra_size);
rv=rval_new_empty(extra_size);
if (likely(rv)){
rv->type=t;
- if (likely(v)){
+ if (likely(v && t!=RV_STR)){
rv->v=*v;
+ }else if (t==RV_STR){
+ rv->v.s.s=&rv->buf[0];
+ rv->v.s.len=0;
+ if (likely(extra_size)) rv->v.s.s[0]=0;
}else
memset (&rv->v, 0, sizeof(rv->v));
}
More information about the sr-dev
mailing list