@@ -67,15 +67,15 @@ static bool string_equals(struct xml_string* a, const char* b) {
6767 return true ;
6868}
6969
70+
7071/* *
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
7274 */
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+
7979
8080/* *
8181 * Tries to parse a simple document containing only one tag
@@ -185,11 +185,11 @@ static void test_xml_parse_document_2() {
185185 (uint8_t *)" Is" , 0 ));
186186 assert_that (!strcmp ((const char *)name_is, " Is" ),
187187 " Name of Parent/This/Is must be `Is'" );
188- delete[] name_is;
188+ free ( name_is) ;
189189 uint8_t * content_a = xml_easy_content (test_a);
190190 assert_that (!strcmp ((const char *)content_a, " Content A" ),
191191 " Content of Parent/This/Is/A/Test must be `Content A'" );
192- delete[] content_a;
192+ free ( content_a) ;
193193 xml_document_free (document, true );
194194}
195195
0 commit comments