sdlMalloc function stdinc

Pointer<NativeType> sdlMalloc(
  1. int size
)

Allocate uninitialized memory.

The allocated memory returned by this function must be freed with SDL_free().

If size is 0, it will be set to 1.

If the allocation is successful, the returned pointer is guaranteed to be aligned to either the fundamental alignment (alignof(max_align_t) in C11 and later) or 2 * sizeof(void *), whichever is smaller. Use SDL_aligned_alloc() if you need to allocate memory aligned to an alignment greater than this guarantee.

\param size the size to allocate. \returns a pointer to the allocated memory, or NULL if allocation failed.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.2.0.

\sa SDL_free \sa SDL_calloc \sa SDL_realloc \sa SDL_aligned_alloc

extern SDL_DECLSPEC SDL_MALLOC void * SDLCALL SDL_malloc(size_t size)

Implementation

Pointer<NativeType> sdlMalloc(int size) {
  final sdlMallocLookupFunction = _libSdl
      .lookupFunction<
        Pointer<NativeType> Function(Uint32 size),
        Pointer<NativeType> Function(int size)
      >('SDL_malloc');
  return sdlMallocLookupFunction(size);
}