My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Classes | Macros | Functions
msu_state.c File Reference

State storage that is tied to a specific MSU message. More...

#include "msu_message.h"
#include "rt_stats.h"
#include "logging.h"
#include "uthash.h"
#include "local_msu.h"

Go to the source code of this file.

Classes

struct  msu_state
 The structure contining msu state. More...
 

Macros

#define CHECK_STATE_REPLACEMENT   1
 Explicitly check whether a state is being replaced on a call to msu_init_state. More...
 

Functions

int msu_num_states (struct local_msu *msu)
 
void * msu_init_state (struct local_msu *msu, struct msu_msg_key *key, size_t size)
 Initializes a new MSU state of the given size with the provided key. More...
 
void * msu_get_state (struct local_msu *msu, struct msu_msg_key *key, size_t *size)
 Gets the state allocated with the given key. More...
 
int msu_free_state (struct local_msu *msu, struct msu_msg_key *key)
 Frees the state assocated with the given MSU and key. More...
 
void msu_free_all_state (struct local_msu *msu)
 Frees all state structures associated with the given MSU. More...
 

Detailed Description

State storage that is tied to a specific MSU message.

Definition in file msu_state.c.

Macro Definition Documentation

#define CHECK_STATE_REPLACEMENT   1

Explicitly check whether a state is being replaced on a call to msu_init_state.

Definition at line 32 of file msu_state.c.

Function Documentation

void msu_free_all_state ( struct local_msu msu)

Frees all state structures associated with the given MSU.

Definition at line 117 of file msu_state.c.

int msu_free_state ( struct local_msu msu,
struct msu_msg_key key 
)

Frees the state assocated with the given MSU and key.

Definition at line 97 of file msu_state.c.

void* msu_get_state ( struct local_msu msu,
struct msu_msg_key key,
size_t *  size 
)

Gets the state allocated with the given key.

Parameters
msuThe MSU storing the state
keyThe key with which the state was allocated
sizeAn output argument, set to the size of the retrieved state if non-NULL
Returns
Allocated state if it exists, otherwise NULL

Definition at line 82 of file msu_state.c.

void* msu_init_state ( struct local_msu msu,
struct msu_msg_key key,
size_t  size 
)

Initializes a new MSU state of the given size with the provided key.

The returned pointer should later be freed with msu_free_state

Returns
a pointer to the newly allocated state, or NULL if error

Definition at line 55 of file msu_state.c.

int msu_num_states ( struct local_msu msu)
Returns
the number of states allocated by the provided MSU

Definition at line 51 of file msu_state.c.