summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-06-22 20:12:44 -0400
committerDavid Robillard <d@drobilla.net>2024-06-22 20:17:07 -0400
commitaab5940036858663eb445c00166511ce2aea9c9d (patch)
treeed96f0b6ccbb1bddb7f6919c28fa2d4479cd4cda
parent503e58d36cd467ce83a7312f55bb8beb4e5e370b (diff)
downloadzix-aab5940036858663eb445c00166511ce2aea9c9d.tar.gz
zix-aab5940036858663eb445c00166511ce2aea9c9d.tar.bz2
zix-aab5940036858663eb445c00166511ce2aea9c9d.zip
Consistently use ZIX_MALLOC_API and ZIX_MALLOC_FUNC
-rw-r--r--include/zix/allocator.h3
-rw-r--r--include/zix/attributes.h2
-rw-r--r--include/zix/filesystem.h8
-rw-r--r--include/zix/ring.h2
-rw-r--r--include/zix/string_view.h2
5 files changed, 10 insertions, 7 deletions
diff --git a/include/zix/allocator.h b/include/zix/allocator.h
index 619697e..e4d813d 100644
--- a/include/zix/allocator.h
+++ b/include/zix/allocator.h
@@ -108,6 +108,7 @@ ZixAllocator* ZIX_NONNULL
zix_default_allocator(void);
/// Convenience wrapper that defers to malloc() if allocator is null
+ZIX_MALLOC_FUNC
static inline void* ZIX_ALLOCATED
zix_malloc(ZixAllocator* const ZIX_NULLABLE allocator, const size_t size)
{
@@ -117,6 +118,7 @@ zix_malloc(ZixAllocator* const ZIX_NULLABLE allocator, const size_t size)
}
/// Convenience wrapper that defers to calloc() if allocator is null
+ZIX_MALLOC_FUNC
static inline void* ZIX_ALLOCATED
zix_calloc(ZixAllocator* const ZIX_NULLABLE allocator,
const size_t nmemb,
@@ -149,6 +151,7 @@ zix_free(ZixAllocator* const ZIX_NULLABLE allocator,
}
/// Convenience wrapper that defers to the system allocator if allocator is null
+ZIX_MALLOC_FUNC
static inline void* ZIX_ALLOCATED
zix_aligned_alloc(ZixAllocator* const ZIX_NULLABLE allocator,
const size_t alignment,
diff --git a/include/zix/attributes.h b/include/zix/attributes.h
index 518e5fb..eddb80e 100644
--- a/include/zix/attributes.h
+++ b/include/zix/attributes.h
@@ -42,7 +42,7 @@
# define ZIX_ALWAYS_INLINE_FUNC ///< Should absolutely always be inlined
# define ZIX_PURE_FUNC ///< Only reads memory
# define ZIX_CONST_FUNC ///< Only reads its parameters
-# define ZIX_MALLOC_FUNC ///< Allocates memory
+# define ZIX_MALLOC_FUNC ///< Allocates memory with no pointers in it
#endif
/// A pure function in the public API that only reads memory
diff --git a/include/zix/filesystem.h b/include/zix/filesystem.h
index 9abafe1..34f7bcb 100644
--- a/include/zix/filesystem.h
+++ b/include/zix/filesystem.h
@@ -146,7 +146,7 @@ zix_create_directory_symlink(const char* ZIX_NONNULL target_path,
@return The path of the created directory, or null.
*/
-ZIX_API
+ZIX_MALLOC_API
char* ZIX_NULLABLE
zix_create_temporary_directory(ZixAllocator* ZIX_NULLABLE allocator,
const char* ZIX_NONNULL path_pattern);
@@ -227,7 +227,7 @@ zix_file_equals(ZixAllocator* ZIX_NULLABLE allocator,
@return A new canonical version of `path`, or null if it doesn't exist.
*/
-ZIX_API
+ZIX_MALLOC_API
char* ZIX_NULLABLE
zix_canonical_path(ZixAllocator* ZIX_NULLABLE allocator,
const char* ZIX_NULLABLE path);
@@ -346,7 +346,7 @@ zix_file_size(const char* ZIX_NONNULL path);
@param allocator Allocator used for the returned path.
*/
-ZIX_API
+ZIX_MALLOC_API
char* ZIX_ALLOCATED
zix_current_path(ZixAllocator* ZIX_NULLABLE allocator);
@@ -357,7 +357,7 @@ zix_current_path(ZixAllocator* ZIX_NULLABLE allocator);
@return A new path to a temporary directory, or null on error.
*/
-ZIX_API
+ZIX_MALLOC_API
char* ZIX_ALLOCATED
zix_temp_directory_path(ZixAllocator* ZIX_NULLABLE allocator);
diff --git a/include/zix/ring.h b/include/zix/ring.h
index 61c99be..a18a50b 100644
--- a/include/zix/ring.h
+++ b/include/zix/ring.h
@@ -40,7 +40,7 @@ typedef struct ZixRingImpl ZixRing;
At most `size` - 1 bytes may be stored in the ring at once.
*/
-ZIX_MALLOC_API
+ZIX_API
ZixRing* ZIX_ALLOCATED
zix_ring_new(ZixAllocator* ZIX_NULLABLE allocator, uint32_t size);
diff --git a/include/zix/string_view.h b/include/zix/string_view.h
index f13f8d1..f463c1f 100644
--- a/include/zix/string_view.h
+++ b/include/zix/string_view.h
@@ -89,7 +89,7 @@ zix_string(const char* const ZIX_NULLABLE str)
/**
Copy a string view into a newly allocated null-terminated string.
*/
-ZIX_API
+ZIX_MALLOC_API
char* ZIX_ALLOCATED
zix_string_view_copy(ZixAllocator* ZIX_NULLABLE allocator, ZixStringView view);