Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

dssi_shm.h File Reference

This file contains functions for handling shared memory in DSSI UIs and plugins. More...

Go to the source code of this file.

UI functions

void * dssi_shm_allocate (size_t bytes, char **key, char **used_flag)
 This function should be used in the UI to allocate a segment of shared memory and generate a key for this segment that can be sent to the plugin.
int dssi_shm_free (const char *key)
 This should always be called by the UI when it wants to deallocate a shared memory segment allocated using dssi_shm_allocate().

Plugin functions

void * dssi_shm_attach (const char *key, void *old_ptr, size_t *size)
 This function should be used by the plugin to attach to a shared memory segment that has been allocated by the UI using dssi_shm_allocate().
int dssi_shm_detach (void *ptr)
 This should always be called by the plugin when it wants to detach from a memory segment that has been attached using dssi_shm_attach().


Detailed Description

This file contains functions for handling shared memory in DSSI UIs and plugins.

It is used by the DSSIUIClient class on the UI side, but can also be used on its own since it has no dependencies on DSSIPlugin or DSSIUIClient, and is written to work in both C and C++ programs. There are a few rules on how to use it (you can of course do whatever you want with it, but if you don't follow the rules it might break):


Function Documentation

void* dssi_shm_allocate size_t  bytes,
char **  key,
char **  used_flag
 

This function should be used in the UI to allocate a segment of shared memory and generate a key for this segment that can be sent to the plugin.

bytes is the requested segment size in bytes. key and used_flag are output parameters, *key will hold a key string for the new segment that you can send to the plugin with a /configure call, and *used_flag will contain a pointer to a char in the shared memory segment that the plugin will set to 1 when it has attached succesfully to the segment. You will have to deallocate *key yourself when you are done with it (using free() instead of delete [] in a C++ program, because it is allocated using calloc()).

Returns:
A pointer to the new segment or NULL

void* dssi_shm_attach const char *  key,
void *  old_ptr,
size_t *  size
 

This function should be used by the plugin to attach to a shared memory segment that has been allocated by the UI using dssi_shm_allocate().

key is the key string received from the UI and old_ptr is a pointer to the old shared memory segment if this is not the first time the plugin tries to attach to a segment. It can be NULL if no segment has been attached earlier.

Returns:
A pointer to the new attached segment or NULL

int dssi_shm_detach void *  ptr  ) 
 

This should always be called by the plugin when it wants to detach from a memory segment that has been attached using dssi_shm_attach().

ptr should be a pointer to the memory segment.

Returns:
The result of a shmdt() call

int dssi_shm_free const char *  key  ) 
 

This should always be called by the UI when it wants to deallocate a shared memory segment allocated using dssi_shm_allocate().

key is the key string generated by the call to dssi_shm_allocate().

Returns:
The result of a shmctl() call


Generated on Wed Mar 1 17:12:44 2006 for DSSI support libraries by  doxygen 1.4.4