ks_malloc.h File Reference

Interface to the libkarmaclient memory management functions. More...

#include <stdlib.h>

Go to the source code of this file.

Typedefs

typedef void *(*) ks_malloc_t (size_t)
typedef void *(*) ks_realloc_t (void *, size_t)
typedef void(*) ks_free_t (void *)

Functions

void ks_malloc_set (ks_malloc_t, ks_realloc_t, ks_free_t)
void * ks_malloc (size_t)
void * ks_realloc (void *, size_t)
void ks_free (void *)


Detailed Description

Interface to the libkarmaclient memory management functions.

Type and function declarations for the functions defined in ks_malloc.c. Do not include this header file directly in applications; instead, include the application header file ks.h which will include all the libkarmaclient header files htat you need.

Definition in file ks_malloc.h.


Typedef Documentation

typedef void(*) ks_free_t(void *)

A pointer to a function with the same prototype as free(3). Objects of this type are used by ks_free() to return memory to the system once libkarmaclient has finished with it.

Definition at line 59 of file ks_malloc.h.

typedef void*(*) ks_malloc_t(size_t)

A pointer to a function with the same prototype as malloc(3). Objects of this type are used by ks_malloc() to allocate memory for libkarmaclient objects. The actual function to be used is set using ks_malloc_set().

Definition at line 44 of file ks_malloc.h.

typedef void*(*) ks_realloc_t(void *, size_t)

A pointer to a function with the same prototype as realloc(3). Objects of this type are used by ks_realloc() to allocate memory for libkarmaclient objects. The actual function to be used is set using ks_malloc_set().

Definition at line 52 of file ks_malloc.h.


Function Documentation

void ks_free ( void *  ptr  ) 

Free the memory pointed to by ptr.

Parameters:
ptr a pointer to the memory we want to free
Returns:
Nothing

Definition at line 122 of file ks_malloc.c.

Referenced by ks_array_fini(), ks_array_free(), ks_assoc_free(), ks_bquery_free(), ks_number_free(), ks_response_free(), ks_socket_free(), ks_socket_send(), ks_socket_set_auth(), and ks_string_free().

void* ks_malloc ( size_t  size  ) 

Allocate a size bytes of memory using the allocation function given to ks_malloc_set().

Parameters:
size the size of the block of memory to be allocated (in bytes)
Returns:
A pointer to the newly allocated memory on success, or NULL on failure

Definition at line 92 of file ks_malloc.c.

Referenced by ks_array_init(), ks_array_new(), ks_assoc_new(), ks_bquery_new(), ks_number_new(), ks_socket_new(), ks_socket_send(), ks_socket_set_auth(), and ks_string_new().

void ks_malloc_set ( ks_malloc_t  m,
ks_realloc_t  r,
ks_free_t  f 
)

Initialise the functions that are actually used for allocating reallocating and freeing allocated memory. If this function is not called, libkarmaclient defaults to using malloc(3), realloc(3) and free(3).

Parameters:
m a pointer to a memory allocation function.
r a pointer to a reallocation function.
f a pointer to a memory freeing function
Returns:
Nothing

Definition at line 75 of file ks_malloc.c.

void* ks_realloc ( void *  ptr,
size_t  size 
)

Allocate a new block of size bytes memory for the object pointed to be ptr.

Parameters:
ptr a pointer to the memory currently allocated for the object.
size the size of the block of memory we wish to allocate for the object pointed to by ptr.
Returns:
a pointer to the newly allocated block of memory on success, or NULL on failure.

Definition at line 109 of file ks_malloc.c.

Referenced by ks_array_extend(), and ks_string_append().


Generated on Wed May 9 01:01:57 2007 for libkarmaclient by  doxygen 1.5.1