node-addon-layer
C API For writing Node modules
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Typedefs | Functions
Buffer methods

Typedefs

typedef void(* shim_buffer_free )(char *, void *)
 

Functions

shim_val_tshim_buffer_new (shim_ctx_t *, size_t)
 
shim_val_tshim_buffer_new_copy (shim_ctx_t *, const char *, size_t)
 
shim_val_tshim_buffer_new_external (shim_ctx_t *, char *, size_t, shim_buffer_free, void *)
 
char * shim_buffer_value (shim_val_t *)
 
size_t shim_buffer_length (shim_val_t *)
 

Detailed Description

Methods for Buffers

Typedef Documentation

typedef void(* shim_buffer_free)(char *, void *)

The callback that will be called when the Buffer is to be freed

Function Documentation

size_t shim_buffer_length ( shim_val_t val)

Get the size of the buffer

Parameters
valThe given buffer
Returns
THe size of the buffer
shim_val_t* shim_buffer_new ( shim_ctx_t ctx,
size_t  len 
)

Create a new buffer of length

Parameters
ctxCurrent executing context
lenSize of buffer to create
Returns
Wrapped buffer
shim_val_t* shim_buffer_new_copy ( shim_ctx_t ctx,
const char *  data,
size_t  len 
)

Copy into a new buffer

Parameters
ctxCurrent executing context
dataData to be copied
lenLength of data to be copied
Returns
Wrapped buffer
shim_val_t* shim_buffer_new_external ( shim_ctx_t ctx,
char *  data,
size_t  len,
shim_buffer_free  cb,
void *  hint 
)

Create a new buffer and be notified when the buffer is to be freed

Parameters
ctxCurrent executing context
dataData to be used for underlying memory
lenSize of memory being used
cbCallback that is called when buffer is to be freed
hintArbitrary data passed to the callback
Returns
Wrapped buffer

The underlying memory is not copied, but used in place

char* shim_buffer_value ( shim_val_t val)

Get the underlying memory for the Buffer

Parameters
valTHe given buffer
Returns
Pointer to the underlying memory