Update to use mem_alloc2, mem_realloc2 and mem_free2

This commit is contained in:
David Snopek
2025-07-17 16:27:27 -05:00
parent 12db0684b2
commit 48d02db27c
4 changed files with 54 additions and 53 deletions

View File

@@ -858,6 +858,7 @@ typedef void (*GDExtensionInterfaceGetGodotVersion2)(GDExtensionGodotVersion2 *r
/**
* @name mem_alloc
* @since 4.1
* @deprecated in Godot 4.6. Use `mem_alloc2` instead.
*
* Allocates memory.
*
@@ -870,6 +871,7 @@ typedef void *(*GDExtensionInterfaceMemAlloc)(size_t p_bytes);
/**
* @name mem_realloc
* @since 4.1
* @deprecated in Godot 4.6. Use `mem_realloc2` instead.
*
* Reallocates memory.
*
@@ -883,6 +885,7 @@ typedef void *(*GDExtensionInterfaceMemRealloc)(void *p_ptr, size_t p_bytes);
/**
* @name mem_free
* @since 4.1
* @deprecated in Godot 4.6. Use `mem_free2` instead.
*
* Frees memory.
*
@@ -890,7 +893,45 @@ typedef void *(*GDExtensionInterfaceMemRealloc)(void *p_ptr, size_t p_bytes);
*/
typedef void (*GDExtensionInterfaceMemFree)(void *p_ptr);
/* INTERFACE: Godot Core */
/**
* @name mem_alloc2
* @since 4.6
*
* Allocates memory.
*
* @param p_bytes The amount of memory to allocate in bytes.
* @param p_pad_align If true, the returned memory will have prepadding of at least 8 bytes.
*
* @return A pointer to the allocated memory, or NULL if unsuccessful.
*/
typedef void *(*GDExtensionInterfaceMemAlloc2)(size_t p_bytes, GDExtensionBool p_pad_align);
/**
* @name mem_realloc2
* @since 4.6
*
* Reallocates memory.
*
* @param p_ptr A pointer to the previously allocated memory.
* @param p_bytes The number of bytes to resize the memory block to.
* @param p_pad_align If true, the returned memory will have prepadding of at least 8 bytes.
*
* @return A pointer to the allocated memory, or NULL if unsuccessful.
*/
typedef void *(*GDExtensionInterfaceMemRealloc2)(void *p_ptr, size_t p_bytes, GDExtensionBool p_pad_align);
/**
* @name mem_free2
* @since 4.6
*
* Frees memory.
*
* @param p_ptr A pointer to the previously allocated memory.
* @param p_pad_align If true, the given memory was allocated with prepadding.
*/
typedef void (*GDExtensionInterfaceMemFree2)(void *p_ptr, GDExtensionBool p_pad_align);
//* INTERFACE: Godot Core */
/**
* @name print_error