logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

SDL_realloc - Change the size of allocated memory.

Availability

       This function is available since SDL 3.2.0.

Description

       The memory returned by this function must be freed with

       SDL_free ().

       If size is 0, it will be set to 1. Note that this is unlike some other C runtime realloc implementations,
       which may treat realloc(mem,0) the same way as free(mem) .

       If mem is NULL, the behavior of this function is equivalent to

       SDL_malloc (). Otherwise, the function can have one of three possible outcomes:

       • If it returns the same pointer as mem , it means that mem was resized
         in place without freeing.

       • If it returns a different non-NULL pointer, it means that mem was freed
         and cannot be dereferenced anymore.

       • If it returns NULL (indicating failure), then mem will remain valid and
         must still be freed with SDL_free ().

       If the allocation is successfully resized, the returned pointer is guaranteed to be aligned to either the
       fundamentalalignment ( alignof(max_align_t) in C11 and later) or 2sizeof(void ) , whichever is smaller.

Function Parameters

mem    a pointer to allocated memory to reallocate, or NULL.

       size   the new size of the memory.

Header File

       Defined in SDL3/SDL_stdinc.h

Name

       SDL_realloc - Change the size of allocated memory.

Return Value

       Returns a pointer to the newly allocated memory, or NULL if allocation failed.

See Also

(3), SDL_free(3), (3), SDL_malloc(3), (3), SDL_calloc(3)

Simple Directmedia Layer                           SDL 3.2.10                                     SDL_realloc(3)

Synopsis

#include"SDL3/SDL.h"void*SDL_realloc(void*mem,size_tsize);

Thread Safety

       It is safe to call this function from any thread.

See Also