aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--serd/serd.h15
-rw-r--r--src/string.c6
-rw-r--r--tests/serd_test.c10
4 files changed, 26 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index 3752c90f..6100c225 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-serd (0.29.3) unstable;
+serd (0.29.4) unstable;
* Clarify errors returned by serd_env_expand()
* Fix reported error when reading statements with only a blank node
@@ -14,6 +14,7 @@ serd (0.29.3) unstable;
* Add NTriples test suite
* Fix building with MSVC
* Clean up testing code
+ * Add serd_free for freeing memory allocated by serd
-- David Robillard <d@drobilla.net> Sun, 27 May 2018 17:51:33 +0200
diff --git a/serd/serd.h b/serd/serd.h
index f3d83515..49a516fa 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -275,6 +275,17 @@ typedef enum {
} SerdStyle;
/**
+ Free memory allocated by Serd.
+
+ This function exists because some systems require memory allocated by a
+ library to be freed by code in the same library. It is otherwise equivalent
+ to the standard C free() function.
+*/
+SERD_API
+void
+serd_free(void* ptr);
+
+/**
@name String Utilities
@{
*/
@@ -316,7 +327,7 @@ serd_strtod(const char* str, char** endptr);
@param str Base64 string to decode.
@param len The length of `str`.
@param size Set to the size of the returned blob in bytes.
- @return A newly allocated blob which must be freed with free().
+ @return A newly allocated blob which must be freed with serd_free().
*/
SERD_API
void*
@@ -386,7 +397,7 @@ serd_uri_to_path(const uint8_t* uri);
@param hostname If non-NULL, set to the hostname, if present.
@return The path component of the URI.
- The returned path and `*hostname` must be freed with free().
+ The returned path and `*hostname` must be freed with serd_free().
*/
SERD_API
uint8_t*
diff --git a/src/string.c b/src/string.c
index d49e1e68..2f79f496 100644
--- a/src/string.c
+++ b/src/string.c
@@ -18,6 +18,12 @@
#include <math.h>
+void
+serd_free(void* ptr)
+{
+ free(ptr);
+}
+
const uint8_t*
serd_strerror(SerdStatus status)
{
diff --git a/tests/serd_test.c b/tests/serd_test.c
index e312ad04..17ef4abd 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -106,8 +106,8 @@ check_file_uri(const char* hostname,
path, node.buf, out_path);
}
- free(out_path);
- free(out_hostname);
+ serd_free(out_path);
+ serd_free(out_hostname);
serd_node_free(&node);
return ret;
}
@@ -222,7 +222,7 @@ main(void)
}
serd_node_free(&blob);
- free(out);
+ serd_free(out);
free(data);
}
@@ -322,7 +322,7 @@ main(void)
if (strcmp((const char*)out_path, "/foo/bar")) {
FAILF("bad tolerance of junk escape: `%s'\n", out_path);
}
- free(out_path);
+ serd_free(out_path);
// Test serd_node_equals
@@ -615,7 +615,7 @@ main(void)
FAILF("Incorrect chunk output:\n%s\n", chunk.buf);
}
- free(out);
+ serd_free(out);
// Rewind and test reader
fseek(fd, 0, SEEK_SET);