Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Files | Data Structures | Macros | Functions

Files

file  afw_memory.h
 Header file for Adaptive Framework Memory.
 

Data Structures

struct  afw_memory_writer_t
 Return value from afw_memory_create_writer(). More...
 

Macros

#define afw_memory_copy(to, from)   memcpy((to), (from), sizeof(*(to)))
 Copy to preallocated memory of same type. More...
 
#define afw_memory_clear(to)   memset((to), 0, sizeof(*(to)))
 Clear preallocated memory for sizeof(*(to)). More...
 

Functions

const afw_memory_tafw_memory_create (const afw_byte_t *ptr, afw_size_t size, const afw_pool_t *p, afw_xctx_t *xctx)
 Create a afw_memory_t struct for a ptr and size. More...
 
void * afw_memory_dup (const void *from, apr_size_t size, const afw_pool_t *p, afw_xctx_t *xctx)
 Duplicate a block of memory into specified pool. More...
 
void afw_memory_encode_base64 (afw_utf8_t *encoded, const afw_memory_t *memory, const afw_pool_t *p, afw_xctx_t *xctx)
 Encode memory to as base64 string. More...
 
void afw_memory_decode_base64 (afw_memory_t *memory, const afw_utf8_t *encoded, const afw_pool_t *p, afw_xctx_t *xctx)
 Decode memory to a base64 string. More...
 
void afw_memory_encode_printable_hex (afw_utf8_t *encoded, const afw_memory_t *memory, const afw_pool_t *p, afw_xctx_t *xctx)
 Encode memory to a printable hex string. More...
 
void afw_memory_decode_printable_hex (afw_memory_t *memory, const afw_utf8_t *encoded, const afw_pool_t *p, afw_xctx_t *xctx)
 Decode memory to a printable hex string. More...
 
const afw_memory_writer_tafw_memory_create_writer (const afw_pool_t *p, afw_xctx_t *xctx)
 Create a memory writer. More...
 
afw_size_t afw_memory_writer_get_current_size (const afw_memory_writer_t *writer, afw_xctx_t *xctx)
 Retrieve memory as one chunk from memory writer and release writer. More...
 
afw_size_t afw_memory_writer_retrieve_using_callback_and_release (const afw_memory_writer_t *writer, void *context, afw_write_cb_t callback, afw_xctx_t *xctx)
 Retrieve memory as using callback. More...
 
const afw_memory_tafw_memory_writer_retrieve_and_release (const afw_memory_writer_t *writer, afw_xctx_t *xctx)
 Retrieve memory as one chunk from memory writer and release writer. More...
 

Detailed Description

Adaptive framework memory support functions.

Macro Definition Documentation

◆ afw_memory_clear

#define afw_memory_clear (   to)    memset((to), 0, sizeof(*(to)))

Clear preallocated memory for sizeof(*(to)).

Parameters
toaddress.

Definition at line 47 of file afw_memory.h.

◆ afw_memory_copy

#define afw_memory_copy (   to,
  from 
)    memcpy((to), (from), sizeof(*(to)))

Copy to preallocated memory of same type.

Parameters
toaddress.
fromaddress.

The size of the type of the variable pointed to by the to parameter is used for the size used by memcpy().

Definition at line 39 of file afw_memory.h.

Function Documentation

◆ afw_memory_create()

const afw_memory_t* afw_memory_create ( const afw_byte_t ptr,
afw_size_t  size,
const afw_pool_t p,
afw_xctx_t xctx 
)

Create a afw_memory_t struct for a ptr and size.

Parameters
ptr.
size
pto use.
xctxof caller.
Returns
Pointer to afw_memory_t.

Definition at line 61 of file afw_memory.h.

◆ afw_memory_create_writer()

const afw_memory_writer_t* afw_memory_create_writer ( const afw_pool_t p,
afw_xctx_t xctx 
)

Create a memory writer.

Parameters
pto use.
xctxof caller.
Returns
memory writer instance.

Definition at line 377 of file afw_memory.c.

◆ afw_memory_decode_base64()

void afw_memory_decode_base64 ( afw_memory_t memory,
const afw_utf8_t encoded,
const afw_pool_t p,
afw_xctx_t xctx 
)

Decode memory to a base64 string.

Parameters
memoryis a afw_memory_t that will be updated with result.
encodedis a base64 encoded string to decode.
pto use.
xctxof caller.

Definition at line 223 of file afw_memory.c.

◆ afw_memory_decode_printable_hex()

void afw_memory_decode_printable_hex ( afw_memory_t memory,
const afw_utf8_t encoded,
const afw_pool_t p,
afw_xctx_t xctx 
)

Decode memory to a printable hex string.

Parameters
memoryis a afw_memory_t that will be updated with result.
encodedis a printable hex encoded string to decode.
pto use.
xctxof caller.

Definition at line 337 of file afw_memory.c.

◆ afw_memory_dup()

void* afw_memory_dup ( const void *  from,
apr_size_t  size,
const afw_pool_t p,
afw_xctx_t xctx 
)

Duplicate a block of memory into specified pool.

Parameters
fromFrom address.
sizeSize of memory to duplicate.
pPool to use.
xctxof caller.
Returns
Pointer to memory allocated or NULL is size is 0.

The default pool from xctx will be used.

Definition at line 88 of file afw_memory.h.

◆ afw_memory_encode_base64()

void afw_memory_encode_base64 ( afw_utf8_t encoded,
const afw_memory_t memory,
const afw_pool_t p,
afw_xctx_t xctx 
)

Encode memory to as base64 string.

Parameters
encodeis a afw_utf8_t that will be updated with result.
memoryto encode.
pto use.
xctxof caller.

Definition at line 185 of file afw_memory.c.

◆ afw_memory_encode_printable_hex()

void afw_memory_encode_printable_hex ( afw_utf8_t encoded,
const afw_memory_t memory,
const afw_pool_t p,
afw_xctx_t xctx 
)

Encode memory to a printable hex string.

Parameters
encodeis a afw_utf8_t that will be updated with result.
memoryto encode.
pto use.
xctxof caller.

Definition at line 310 of file afw_memory.c.

◆ afw_memory_writer_get_current_size()

afw_size_t afw_memory_writer_get_current_size ( const afw_memory_writer_t writer,
afw_xctx_t xctx 
)

Retrieve memory as one chunk from memory writer and release writer.

Parameters
writerinstance of memory writer.
xctxof caller.
Returns
current total number of octets in buffer.

Definition at line 401 of file afw_memory.c.

◆ afw_memory_writer_retrieve_and_release()

const afw_memory_t* afw_memory_writer_retrieve_and_release ( const afw_memory_writer_t writer,
afw_xctx_t xctx 
)

Retrieve memory as one chunk from memory writer and release writer.

Parameters
writerinstance of memory writer.
xctxof caller.
Returns
memory in pool specified on afw_memory_create_writer().

Definition at line 441 of file afw_memory.c.

◆ afw_memory_writer_retrieve_using_callback_and_release()

afw_size_t afw_memory_writer_retrieve_using_callback_and_release ( const afw_memory_writer_t writer,
void *  context,
afw_write_cb_t  callback,
afw_xctx_t xctx 
)

Retrieve memory as using callback.

Parameters
writerinstance of memory writer.
contextto pass to callback.
callbackto call.
xctxof caller.
Returns
total number of octets written to callback.

Definition at line 418 of file afw_memory.c.