Browse code

core: pv api - use buffers for empty and null values

- safer if any transformation wants to temporary update the value for
some operations

Daniel-Constantin Mierla authored on 16/07/2015 10:21:34
Showing 1 changed files
... ...
@@ -592,6 +592,9 @@ static int pv_get_marker(struct sip_msg *msg, pv_param_t *param,
592 592
 			(int)pv_str_marker.s[0]);
593 593
 }
594 594
 
595
+static char pv_str_empty_buf[2];
596
+static char pv_str_null_buf[8];
597
+
595 598
 static str pv_str_empty  = { "", 0 };
596 599
 static str pv_str_null   = { "<null>", 6 };
597 600
 int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
... ...
@@ -1890,6 +1893,13 @@ int pv_init_api(void)
1890 1893
 	tr_init_table();
1891 1894
 	if(pv_init_buffer()<0)
1892 1895
 		return -1;
1896
+
1897
+	pv_str_empty_buf[0] = '\0';
1898
+	pv_str_empty_buf[1] = '\0';
1899
+	pv_str_empty.s = pv_str_empty_buf;
1900
+	strcpy(pv_str_null_buf, "<null>");
1901
+	pv_str_null.s = pv_str_null_buf;
1902
+
1893 1903
 	if(register_pvars_mod("core", _core_pvs)<0)
1894 1904
 		return -1;
1895 1905
 	return 0;