Procházet zdrojové kódy

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

Vaclav Kubart před 19 roky
rodič
revize
354dc8ab1d
4 změnil soubory, kde provedl 8 přidání a 13 odebrání
  1. 5 1
      lib/cds/dstring.c
  2. 1 4
      lib/presence/lpidf.c
  3. 1 4
      lib/presence/pidf.c
  4. 1 4
      lib/presence/xpidf.c

+ 5 - 1
lib/cds/dstring.c

@@ -124,7 +124,11 @@ int dstr_get_str(dstring_t *dstr, str_t *dst)
 			dst->s = NULL;
 		}
 		else res = dstr_get_data(dstr, dst->s);
-	} else dst->s = NULL;
+	} 
+	else {
+		dst->s = NULL;
+		dst->len = 0;
+	}
 
 	return res;
 }

+ 1 - 4
lib/presence/lpidf.c

@@ -83,10 +83,7 @@ int create_lpidf_document(presentity_info_t *p, str_t *dst, str_t *dst_content_t
 	
 	doc_add_presentity(&buf, p);
 	
-	dst->len = dstr_get_data_length(&buf);
-	dst->s = cds_malloc(dst->len);
-	if (!dst->s) dst->len = 0;
-	else dstr_get_data(&buf, dst->s);
+	dstr_get_str(&buf, dst);
 	dstr_destroy(&buf);
 	
 	return 0;

+ 1 - 4
lib/presence/pidf.c

@@ -199,10 +199,7 @@ int create_pidf_document_ex(presentity_info_t *p, str_t *dst, str_t *dst_content
 	dstr_append_zt(&buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
 	doc_add_presentity(&buf, p, use_cpim_pidf_ns);
 	
-	dst->len = dstr_get_data_length(&buf);
-	dst->s = cds_malloc(dst->len);
-	if (!dst->s) dst->len = 0;
-	else dstr_get_data(&buf, dst->s);
+	dstr_get_str(&buf, dst);
 	dstr_destroy(&buf);
 	
 	return 0;

+ 1 - 4
lib/presence/xpidf.c

@@ -151,10 +151,7 @@ int create_xpidf_document(presentity_info_t *p, str_t *dst, str_t *dst_content_t
 	dstr_append_zt(&buf, "<!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\r\n");
 	doc_add_presentity(&buf, p);
 	
-	dst->len = dstr_get_data_length(&buf);
-	dst->s = cds_malloc(dst->len);
-	if (!dst->s) dst->len = 0;
-	else dstr_get_data(&buf, dst->s);
+	dstr_get_str(&buf, dst);
 	dstr_destroy(&buf);
 	
 	return 0;