Browse code

corrected bugs: under heavy load vere allocated buffers with zero length, but they were not freed

Vaclav Kubart authored on 27/02/2006 11:43:03
Showing 4 changed files
... ...
@@ -124,7 +124,11 @@ int dstr_get_str(dstring_t *dstr, str_t *dst)
124 124
 			dst->s = NULL;
125 125
 		}
126 126
 		else res = dstr_get_data(dstr, dst->s);
127
-	} else dst->s = NULL;
127
+	} 
128
+	else {
129
+		dst->s = NULL;
130
+		dst->len = 0;
131
+	}
128 132
 
129 133
 	return res;
130 134
 }
... ...
@@ -83,10 +83,7 @@ int create_lpidf_document(presentity_info_t *p, str_t *dst, str_t *dst_content_t
83 83
 	
84 84
 	doc_add_presentity(&buf, p);
85 85
 	
86
-	dst->len = dstr_get_data_length(&buf);
87
-	dst->s = cds_malloc(dst->len);
88
-	if (!dst->s) dst->len = 0;
89
-	else dstr_get_data(&buf, dst->s);
86
+	dstr_get_str(&buf, dst);
90 87
 	dstr_destroy(&buf);
91 88
 	
92 89
 	return 0;
... ...
@@ -199,10 +199,7 @@ int create_pidf_document_ex(presentity_info_t *p, str_t *dst, str_t *dst_content
199 199
 	dstr_append_zt(&buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
200 200
 	doc_add_presentity(&buf, p, use_cpim_pidf_ns);
201 201
 	
202
-	dst->len = dstr_get_data_length(&buf);
203
-	dst->s = cds_malloc(dst->len);
204
-	if (!dst->s) dst->len = 0;
205
-	else dstr_get_data(&buf, dst->s);
202
+	dstr_get_str(&buf, dst);
206 203
 	dstr_destroy(&buf);
207 204
 	
208 205
 	return 0;
... ...
@@ -151,10 +151,7 @@ int create_xpidf_document(presentity_info_t *p, str_t *dst, str_t *dst_content_t
151 151
 	dstr_append_zt(&buf, "<!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\r\n");
152 152
 	doc_add_presentity(&buf, p);
153 153
 	
154
-	dst->len = dstr_get_data_length(&buf);
155
-	dst->s = cds_malloc(dst->len);
156
-	if (!dst->s) dst->len = 0;
157
-	else dstr_get_data(&buf, dst->s);
154
+	dstr_get_str(&buf, dst);
158 155
 	dstr_destroy(&buf);
159 156
 	
160 157
 	return 0;