Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Argument buffer

The argument buffer can be used when passing an argument from an exiting process to a process that has not been created yet.

Since the exiting process will have exited when the new process is started, the argument cannot be passed in any of the processes' addres spaces. In such situations, the argument buffer can be used.

The argument buffer is statically allocated in memory and is globally accessible to all processes.

An argument buffer is allocated with the arg_alloc() function and deallocated with the arg_free() function. The arg_free() function is designed so that it can take any pointer, not just an argument buffer pointer. If the pointer to arg_free() is not an argument buffer, the function does nothing.

Data Structures

struct  argbuf
 

Functions

char * arg_alloc (char size)
 Allocates an argument buffer. More...
 
void arg_free (char *arg)
 Deallocates an argument buffer. More...
 
void arg_init (void)
 

Variables

static struct argbuf bufs [1]
 

char* arg_alloc ( char  size)

Allocates an argument buffer.

Parameters
sizeThe requested size of the buffer, in bytes.
Returns
Pointer to allocated buffer, or NULL if no buffer could be allocated.
Note
It currently is not possible to allocate argument buffers of any other size than 128 bytes.

References argbuf::buf, bufs, and argbuf::used.

void arg_free ( char *  arg)

Deallocates an argument buffer.

This function deallocates the argument buffer pointed to by the parameter, but only if the buffer actually is an argument buffer and is allocated. It is perfectly safe to call this function with any pointer.

Parameters
argA pointer.

References buf, bufs, and argbuf::used.

void arg_init ( void  )

Initalizer, called by the dispatcher module.

References bufs, and argbuf::used.

struct argbuf bufs[1]
static

Referenced by arg_alloc(), arg_free(), and arg_init().