Orcania: Memory functions

Orcania Potluck with different functions for different purposes that can be shared among C programs

Loading...
Searching...
No Matches
Typedefs | Functions
Memory functions

## Typedefs
typedef void *(* | o_malloc_t) (size_t)
typedef void *(* | o_realloc_t) (void *, size_t)
typedef void(* | o_free_t) (void *)

## Functions
void * | o_malloc (size_t size)
void * | o_realloc (void *ptr, size_t size)
void | o_free (void *ptr)
void | o_set_alloc_funcs (o_malloc_t malloc_fn, o_realloc_t realloc_fn, o_free_t free_fn)
void | o_get_alloc_funcs (o_malloc_t *malloc_fn, o_realloc_t *realloc_fn, o_free_t *free_fn)

## Detailed Description

## Typedef Documentation

## ◆ o_free_t

typedef void(* o_free_t) (void *)

## ◆ o_malloc_t

typedef void *(* o_malloc_t) (size_t)

typedefs use to replace glib's memory functions

## ◆ o_realloc_t

typedef void *(* o_realloc_t) (void *, size_t)

## Function Documentation

## ◆ o_free()

void o_free | ( | void * | ptr | ) |

Free a block allocated by o_malloc

## ◆ o_get_alloc_funcs()

void o_get_alloc_funcs | ( | o_malloc_t * | malloc_fn,
|  | o_realloc_t * | realloc_fn,
|  | o_free_t * | free_fn
| ) |  |

Gets the pointer to current memory functions

Parameters

  malloc_fn | reference to a pointer to a malloc function
  realloc_fn | reference to a pointer to a realloc function
  free_fn | reference to a pointer to a free function

## ◆ o_malloc()

void * o_malloc | ( | size_t | size | ) |

Allocate a memory block

Parameters

  size | the size of the block to allocate in memory

Returns
  a pointer to the new allocated block

## ◆ o_realloc()

void * o_realloc | ( | void * | ptr,
|  | size_t | size
| ) |  |

Reallocate a memory block

Parameters

  ptr | the previous memory block that will be free'd
  size | the size of the block to allocate in memory

Returns
  a pointer to the new allocated block with a copy of the data previously in ptr

## ◆ o_set_alloc_funcs()

void o_set_alloc_funcs | ( | o_malloc_t | malloc_fn,
|  | o_realloc_t | realloc_fn,
|  | o_free_t | free_fn
| ) |  |

Updates the memory functions by user-specific ones

Parameters

  malloc_fn | a pointer to a malloc function, if NULL, will use current function
  realloc_fn | a pointer to a realloc function, if NULL, will use current function
  free_fn | a pointer to a free function, if NULL, will use current function