Skip to content

Commit 5ceb656

Browse files
committed
SDL3 SDL_malloc & SDL_free
1 parent 48a2302 commit 5ceb656

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/sdl3.zig

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1662,9 +1662,30 @@ extern fn SDL_ShowSimpleMessageBox(
16621662

16631663
//--------------------------------------------------------------------------------------------------
16641664
//
1665-
// Standard Library Functionality
1665+
// "Standard Library" Functionality
16661666
//
16671667
//--------------------------------------------------------------------------------------------------
16681668
pub const Bool = c_int;
16691669
pub const False = @as(Bool, 0);
16701670
pub const True = @as(Bool, 1);
1671+
1672+
/// Allocate uinitialized memory.
1673+
///
1674+
/// The allocated memory returned by this function must be freed with SDL_free().
1675+
///
1676+
/// If `size` is 0, it will be set to 1.
1677+
///
1678+
/// If you want to allocate memory aligned to a specific alignment, consider using SDL_aligned_alloc().
1679+
///
1680+
/// Returns a pointer to the allocated memory, or NULL if allocation failed.
1681+
pub const malloc = SDL_malloc;
1682+
extern fn SDL_malloc(isize) *anyopaque;
1683+
1684+
/// Free allocated memory.
1685+
/// The pointer is no longer valid after this call and cannot be dereferenced anymore.
1686+
pub const free = SDL_free;
1687+
extern fn SDL_free(*anyopaque) void;
1688+
1689+
// TODO
1690+
// - Declare SDL_malloc_func, SDL_calloc_func, SDL_realloc_func and SDL_free_func
1691+
// - Zig Allocator interface

0 commit comments

Comments
 (0)