PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
alloc.c File Reference
#include <stdarg.h>
#include "types.h"
#include "defs.h"
#include "alloc.h"
#include "irx_imports.h"
+ Include dependency graph for alloc.c:

Go to the source code of this file.

Data Structures

struct  _heap_mem_header
 

Macros

#define MODNAME   "alloc"
 
#define DEFAULT_HEAP_SIZE   128 * 1024
 
#define DEFAULT_ALIGNMENT   16
 
#define ALIGN(x, align)
 

Typedefs

typedef struct _heap_mem_header heap_mem_header_t
 

Functions

 IRX_ID ("Basic alloc library", 1, 1)
 
static void alloc_lock ()
 
static void alloc_unlock ()
 
int _start (int argc, char *argv[])
 
int shutdown ()
 
static void * alloc_sbrk (size_t increment)
 
static heap_mem_header_t_heap_mem_fit (heap_mem_header_t *head, size_t size)
 
void * malloc (size_t size)
 
void * realloc (void *ptr, size_t size)
 
void * calloc (size_t n, size_t size)
 
void * memalign (size_t align, size_t size)
 
void free (void *ptr)
 
void * __mem_walk_begin ()
 
void __mem_walk_read (void *token, u32 *size, void **ptr, int *valid)
 
void * __mem_walk_inc (void *token)
 
int __mem_walk_end (void *token)
 

Variables

struct irx_export_table _exp_alloc
 
static vs32 alloc_sema = -1
 
u32 heap_size = DEFAULT_HEAP_SIZE
 
static u8 * heap_start
 
static u8 * heap_end
 
static u8 * _heap_ptr
 
static void * __alloc_heap_base = NULL
 
static heap_mem_header_t__alloc_heap_head = NULL
 
static heap_mem_header_t__alloc_heap_tail = NULL
 

Detailed Description

Basic alloc library

Definition in file alloc.c.


Data Structure Documentation

◆ _heap_mem_header

struct _heap_mem_header

Definition at line 96 of file alloc.c.

+ Collaboration diagram for _heap_mem_header:
Data Fields
void * ptr
size_t size
struct _heap_mem_header * prev
struct _heap_mem_header * next

Macro Definition Documentation

◆ MODNAME

#define MODNAME   "alloc"

Definition at line 25 of file alloc.c.

◆ DEFAULT_HEAP_SIZE

#define DEFAULT_HEAP_SIZE   128 * 1024

Definition at line 32 of file alloc.c.

◆ DEFAULT_ALIGNMENT

#define DEFAULT_ALIGNMENT   16

Use this to set the default malloc() alignment.

Definition at line 89 of file alloc.c.

◆ ALIGN

#define ALIGN ( x,
align )
Value:
(((x)+((align)-1))&~((align)-1))

Definition at line 92 of file alloc.c.

Function Documentation

◆ alloc_lock()

static void alloc_lock ( )
static

Definition at line 37 of file alloc.c.

◆ alloc_unlock()

static void alloc_unlock ( )
static

Definition at line 43 of file alloc.c.

◆ _start()

int _start ( int argc,
char * argv[] )

Definition at line 49 of file alloc.c.

◆ shutdown()

int shutdown ( void )

Definition at line 77 of file alloc.c.

◆ alloc_sbrk()

static void * alloc_sbrk ( size_t increment)
static

Definition at line 107 of file alloc.c.

◆ _heap_mem_fit()

static heap_mem_header_t * _heap_mem_fit ( heap_mem_header_t * head,
size_t size )
static

Find the lowest block that we can allocate AFTER, returning NULL if there are none.

Definition at line 125 of file alloc.c.

◆ malloc()

void * malloc ( size_t size)

Definition at line 144 of file alloc.c.

◆ realloc()

void * realloc ( void * ptr,
size_t size )

Definition at line 242 of file alloc.c.

◆ calloc()

void * calloc ( size_t n,
size_t size )

Definition at line 309 of file alloc.c.

◆ memalign()

void * memalign ( size_t align,
size_t size )

Definition at line 321 of file alloc.c.

◆ free()

void free ( void * ptr)

Definition at line 372 of file alloc.c.

◆ __mem_walk_begin()

void * __mem_walk_begin ( )

Definition at line 439 of file alloc.c.

◆ __mem_walk_read()

void __mem_walk_read ( void * token,
u32 * size,
void ** ptr,
int * valid )

Definition at line 443 of file alloc.c.

◆ __mem_walk_inc()

void * __mem_walk_inc ( void * token)

Definition at line 452 of file alloc.c.

◆ __mem_walk_end()

int __mem_walk_end ( void * token)

Definition at line 458 of file alloc.c.

Variable Documentation

◆ alloc_sema

vs32 alloc_sema = -1
static

Definition at line 30 of file alloc.c.

◆ heap_size

u32 heap_size = DEFAULT_HEAP_SIZE

Definition at line 34 of file alloc.c.

◆ heap_start

u8* heap_start
static

Definition at line 35 of file alloc.c.

◆ heap_end

u8 * heap_end
static

Definition at line 35 of file alloc.c.

◆ _heap_ptr

u8 * _heap_ptr
static

Definition at line 35 of file alloc.c.

◆ __alloc_heap_base

void* __alloc_heap_base = NULL
static

Definition at line 103 of file alloc.c.

◆ __alloc_heap_head

heap_mem_header_t* __alloc_heap_head = NULL
static

Definition at line 104 of file alloc.c.

◆ __alloc_heap_tail

heap_mem_header_t* __alloc_heap_tail = NULL
static

Definition at line 105 of file alloc.c.