Skip to content

Commit 16fc76f

Browse files
authored
Merge pull request #10 from ooxi/patch/fix-test-cpp
malloc/free must be used instead of new/delete
2 parents aa71b65 + f800fc8 commit 16fc76f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/test-xml-cpp.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)