include/Zy...llocator.h(3)

πŸ“¦
version 1.5.2 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– include/Zycore/Allocator.h πŸ’–

okay so bestie, you opened a page from the Library Functions Manual β€” it's the include/Zycore/Allocator.h entry β€” and I'm about to make allocators make sense. this whole thing is Doxygen-generated docs for Zycore's allocator header, so let's get into it 🌸


✨ NAME ✨

include/Zycore/Allocator.h β€” the header where Zycore keeps its allocator class and function prototypes 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <Zycore/Status.h>
#include <Zycore/Types.h>

🌈 Classes

  • struct ZyanAllocator_

πŸ¦‹ Typedefs

  • typedef ZyanStatus(* ZyanAllocatorAllocate) (struct ZyanAllocator_ *allocator, void **p, ZyanUSize element_size, ZyanUSize n)
  • typedef ZyanStatus(* ZyanAllocatorDeallocate) (struct ZyanAllocator_ *allocator, void *p, ZyanUSize element_size, ZyanUSize n)
  • typedef struct ZyanAllocator_ ZyanAllocator

⭐ Functions

  • ZYCORE_EXPORT ZyanStatus ZyanAllocatorInit (ZyanAllocator *allocator, ZyanAllocatorAllocate allocate, ZyanAllocatorAllocate reallocate, ZyanAllocatorDeallocate deallocate)
  • ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanAllocator * ZyanAllocatorDefault (void)

πŸ‘‘ Typedef Documentation πŸ‘‘

πŸ’œ typedef struct ZyanAllocator_ ZyanAllocator

Defines the ZyanAllocator struct. periodt.

This is the base class for all custom allocator implementations β€” if you're building your own allocator vibe, this is the blueprint, iykyk.

🚨 All fields in this struct should be considered as "private". Any changes may lead to unexpected behavior. like fr fr, hands off the internals, bestie. she's not yours.

🌸 typedef ZyanStatus(* ZyanAllocatorAllocate) (struct ZyanAllocator_ *allocator, void **p, ZyanUSize element_size, ZyanUSize n)

Defines the ZyanAllocatorAllocate function prototype. this is the shape your allocate function has to have, no cap.

Parameters

  • allocator β€” A pointer to the ZyanAllocator instance.
  • p β€” Receives a pointer to the first memory block sufficient to hold an array of n elements with a size of element_size.
  • element_size β€” The size of a single element.
  • n β€” The number of elements to allocate storage for.

Returns

  • A zyan status code.

This prototype is used for the allocate() and reallocate() functions β€” one signature, two jobs, multitasking queen πŸ’…

😭 The result of the reallocate() function is undefined, if p does not point to a memory block previously obtained by (re-)allocate(). undefined behavior means undefined behavior, bestie. do not pass her a random pointer and act surprised.

🧚 typedef ZyanStatus(* ZyanAllocatorDeallocate) (struct ZyanAllocator_ *allocator, void *p, ZyanUSize element_size, ZyanUSize n)

Defines the ZyanAllocatorDeallocate function prototype β€” the cleanup era.

Parameters

  • allocator β€” A pointer to the ZyanAllocator instance.
  • p β€” The pointer obtained from (re-)allocate().
  • element_size β€” The size of a single element.
  • n β€” The number of elements earlier passed to (re-)allocate().

Returns

  • A zyan status code.

πŸ”₯ Function Documentation πŸ”₯

πŸ’… ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanAllocator * ZyanAllocatorDefault (void)

Returns the default ZyanAllocator instance. the main character of allocators ✨

Returns

  • A pointer to the default ZyanAllocator instance.

The default allocator uses the default memory manager to allocate memory on the heap.

🚫 You should in no case modify the returned allocator instance to avoid unexpected behavior. not even a little. not even a tiny field. leave her alone, she's thriving.

πŸ“ ZYCORE_EXPORT ZyanStatus ZyanAllocatorInit (ZyanAllocator * allocator, ZyanAllocatorAllocate allocate, ZyanAllocatorAllocate reallocate, ZyanAllocatorDeallocate deallocate)

Initializes the given ZyanAllocator instance. set her up, hand her the callbacks, done.

Parameters

  • allocator β€” A pointer to the ZyanAllocator instance.
  • allocate β€” The allocate function.
  • reallocate β€” The reallocate function.
  • deallocate β€” The deallocate function.

Returns

  • A zyan status code.
πŸ’€ also yes, allocate and reallocate are both declared as ZyanAllocatorAllocate up there β€” that's genuinely what the header says, I'm not making it up, and the typedef docs literally tell you the same prototype covers both. slay.

🌈 Author 🌈

Generated automatically by Doxygen for Zycore from the source code. she didn't write herself, bestie, a tool did it πŸŽ€


and that's the whole page!! this one lives in Zycore, Version 1.5.2.0, and the footer doesn't carry a date so there's no date to give you β€” just the source <rainbow>Zycore</rainbow> and that version number. go forth and allocate responsibly πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from