@@ -67,15 +67,15 @@ static bool string_equals(struct xml_string* a, const char* b) {
67
67
return true ;
68
68
}
69
69
70
+
70
71
/* *
71
- * Converts a static character array to an uint8_t data source
72
+ * Converts a static character array to an uint8_t data source which can be
73
+ * freed
72
74
*/
73
- #define SOURCE (source, content ) \
74
- uint8_t * source = new uint8_t [strlen(content)]; \
75
- { \
76
- const char * content_string = content; \
77
- memcpy (source, content_string, strlen (content) + 1 ); \
78
- }
75
+ #define SOURCE (source, content ) \
76
+ uint8_t * source = (uint8_t *)calloc(strlen(content) + 1 , sizeof (uint8_t )); \
77
+ memcpy (source, (content), strlen(content) + 1); \
78
+
79
79
80
80
/* *
81
81
* Tries to parse a simple document containing only one tag
@@ -185,11 +185,11 @@ static void test_xml_parse_document_2() {
185
185
(uint8_t *)" Is" , 0 ));
186
186
assert_that (!strcmp ((const char *)name_is, " Is" ),
187
187
" Name of Parent/This/Is must be `Is'" );
188
- delete[] name_is;
188
+ free ( name_is) ;
189
189
uint8_t * content_a = xml_easy_content (test_a);
190
190
assert_that (!strcmp ((const char *)content_a, " Content A" ),
191
191
" Content of Parent/This/Is/A/Test must be `Content A'" );
192
- delete[] content_a;
192
+ free ( content_a) ;
193
193
xml_document_free (document, true );
194
194
}
195
195
0 commit comments