nfs-ganesha 1.4
Classes | Typedefs

abstract_mem.h File Reference

Abstract memory shims to allow swapping out allocators. More...

#include <stdlib.h>
#include <string.h>
#include <assert.h>

Go to the source code of this file.

Classes

struct  pool_substrate_vector
 A function vector defining a pool substrate. More...
struct  pool
 Type representing a pool. More...

Typedefs

typedef struct pool pool_t
typedef pool_t *(* pool_initializer_t )(size_t size, void *param)
 Abstract type of pool initializer.
typedef void(* pool_destroyer_t )(pool_t *pool)
 Abstract type of pool destroyer.
typedef void *(* pool_allocator_t )(pool_t *pool)
 Abstract type of pool allocator.
typedef void(* pool_freer_t )(pool_t *pool, void *object)
 Abstract type of pool freer.
typedef void(* pool_constructor_t )(void *object, void *parameters)
 Object constructor.
typedef void(* pool_destructor_t )(void *object)
 Object destructor.

Detailed Description

Abstract memory shims to allow swapping out allocators.

Author:
Adam C. Emerson <aemerson@linuxbox.com> This file's purpose is to allow us to easily replace the memory allocator used by Ganesha. Further, it provides a pool abstraction that may be implemented in terms of the normal allocator that may be expanded at a later date. These are intended to be thin wrappers, but conditionally compiled trace information could be added.

Definition in file abstract_mem.h.


Typedef Documentation

typedef void*(* pool_allocator_t)(pool_t *pool)

Abstract type of pool allocator.

This type represents that of a function to perform the allocation of an object in the underlying pool implementation. It must not call the constructor function, leaving that to the wrapper.

Parameters:
[in]poolThe pool from which to allocate.
Returns:
the allocated object or NULL.

Definition at line 239 of file abstract_mem.h.

typedef void(* pool_constructor_t)(void *object, void *parameters)

Object constructor.

Functions of this type are used to initialize objects newly allocated from the pool.

Parameters:
[out]objectThe newly allocated object to be initialized
[in]parametersParameters to be used in initialization

Definition at line 281 of file abstract_mem.h.

typedef void(* pool_destroyer_t)(pool_t *pool)

Abstract type of pool destroyer.

This type represents that of a function to perform the destruction of an underlying pool. It should do any substrate specific cleanup and then deallocate the memory pointed to by the pool argment.

Parameters:
[in]poolThe pool to destroy

Definition at line 225 of file abstract_mem.h.

typedef void(* pool_destructor_t)(void *object)

Object destructor.

Functions of this type are used to finalize objects before they are returned to the pool.

Parameters:
[in,out]objectThe object to be finalized

Definition at line 293 of file abstract_mem.h.

typedef void(* pool_freer_t)(pool_t *pool, void *object)

Abstract type of pool freer.

This type represents that of a function to free an object in the underlying pool implementation. It must not call the destructor function, leaving that to the wrapper.

Parameters:
[in]poolThe pool to which to return the object
[in]objectThe object to free

Definition at line 253 of file abstract_mem.h.

typedef pool_t*(* pool_initializer_t)(size_t size, void *param)

Abstract type of pool initializer.

This type represents that of a function to perform the initialization of the underlying pool. It should allocate the pool_t and other memory it needs in a contiguous block, initialize its own substrate-specific data, and return the pointer to the pool_t (without filling out any of the fields in the pool_t proper.)

Parameters:
[in]sizeSize of the objects to be allocated
[in]paramSubstrate specific parameters
Returns:
the pointer to the pool_t or NULL on failure

Definition at line 212 of file abstract_mem.h.

typedef struct pool pool_t

Definition at line 194 of file abstract_mem.h.