Nugget
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
alloc.c File Reference
#include "psyqo/alloc.h"
#include <stddef.h>
#include <stdint.h>
#include "common/hardware/pcsxhw.h"
#include "psyqo/xprintf.h"
Include dependency graph for alloc.c:

Classes

struct  empty_block_
 
struct  allocated_block_
 

Macros

#define ALIGN_MASK   ((2 * sizeof(void *)) - 1)
 
#define ALIGN_TO(x)   (((uintptr_t)(x) + ALIGN_MASK) & ~ALIGN_MASK)
 
#define dprintf(...)
 
#define print_block(x)
 
#define check_integrity()
 

Typedefs

typedef struct empty_block_ empty_block
 
typedef struct allocated_block_ allocated_block
 

Functions

voidpsyqo_malloc (size_t size_)
 Allocates memory from the heap.
 
void psyqo_free (void *ptr_)
 Frees memory from the heap.
 
voidpsyqo_realloc (void *ptr_, size_t size_)
 Re-allocates memory from the heap.
 
void__builtin_new (size_t size)
 
void __builtin_delete (void *ptr)
 
void_Znwj (unsigned int size)
 
void_Znaj (unsigned int size)
 
void _ZdlPv (void *ptr)
 
void _ZdaPv (void *ptr)
 
void _ZdlPvj (void *ptr, unsigned int size)
 
void _ZdaPvj (void *ptr, unsigned int size)
 
voidpsyqo_heap_start ()
 Returns the pointer to the beginning of the heap.
 
voidpsyqo_heap_end ()
 Returns the pointer to the end of the heap.
 

Variables

char __heap_start
 
char __stack_start
 

Macro Definition Documentation

◆ ALIGN_MASK

#define ALIGN_MASK   ((2 * sizeof(void *)) - 1)

◆ ALIGN_TO

#define ALIGN_TO (   x)    (((uintptr_t)(x) + ALIGN_MASK) & ~ALIGN_MASK)

◆ check_integrity

#define check_integrity ( )

◆ dprintf

#define dprintf (   ...)

◆ print_block

#define print_block (   x)

Typedef Documentation

◆ allocated_block

◆ empty_block

Function Documentation

◆ __builtin_delete()

void __builtin_delete ( void ptr)

◆ __builtin_new()

void * __builtin_new ( size_t  size)

◆ _ZdaPv()

void _ZdaPv ( void ptr)

◆ _ZdaPvj()

void _ZdaPvj ( void ptr,
unsigned int  size 
)

◆ _ZdlPv()

void _ZdlPv ( void ptr)

◆ _ZdlPvj()

void _ZdlPvj ( void ptr,
unsigned int  size 
)

◆ _Znaj()

void * _Znaj ( unsigned int  size)

◆ _Znwj()

void * _Znwj ( unsigned int  size)

◆ psyqo_free()

void psyqo_free ( void ptr)

Frees memory from the heap.

This function behaves as you'd expect from typical free. Calling this function with a NULL pointer is a no-op.

Parameters
ptrThe pointer to the memory to free.

◆ psyqo_heap_end()

void * psyqo_heap_end ( )

Returns the pointer to the end of the heap.

This function will return the pointer to the end of the heap. The heap works lazily, and this function may return a NULL pointer. Once it returns a non-NULL pointer, it will approximately correspond to the current end of the heap. The heap may actually be larger than this pointer on occasion. The heap will always grow, and never shrink.

Returns
void* The end of the heap.

◆ psyqo_heap_start()

void * psyqo_heap_start ( )

Returns the pointer to the beginning of the heap.

This function will return the pointer to the beginning of the heap. The heap works lazily, and this function may return a NULL pointer, but once it returns a non-NULL pointer, it will always return the same pointer.

Returns
void* The beginning of the heap.

◆ psyqo_malloc()

void * psyqo_malloc ( size_t  size)

Allocates memory from the heap.

This function behaves as you'd expect from typical malloc. Allocating 0 bytes will return a valid pointer, which can be freed. Guarantees to align the memory to 8 bytes.

Parameters
sizeThe amount of bytes to allocate.
Returns
void* The memory allocated.

◆ psyqo_realloc()

void * psyqo_realloc ( void ptr,
size_t  size 
)

Re-allocates memory from the heap.

This function behaves as you'd expect from typical realloc. Allocating 0 bytes with a NULL pointer will return a valid pointer, which can be freed. Allocating 0 bytes with a valid pointer will behave as if free was called. Re-allocating a pointer to a smaller size is always guaranteed to succeed and to return the same pointer. Re-allocating a pointer to a larger size may fail, in which case, it will return NULL. Passing a NULL pointer will behave like a call to malloc.

Parameters
ptrThe pointer to the memory to re-allocate.
sizeThe amount of bytes to allocate.
Returns
void* The memory allocated.

Variable Documentation

◆ __heap_start

char __heap_start
extern

◆ __stack_start

char __stack_start
extern