MWALLOC

Section: MidWay Programmer's Manual (3C)
Updated: DATE
Index Return to Main Contents
 

NAME

mwalloc, mwrealloc mwfree - Allocate and free MidWay Shared memory buffers.  

SYNOPSIS

#include <MidWay.h>

char * mwalloc (unsigned int size);
char * mwrealloc(char * buffer, unsigned int newsize);
void mwfree(char * buffer);  

DESCRIPTION

MidWay uses buffers in a shared memory segment to pass data to and from processes, such as by mwcall(). Even if mwcall() and is like don't require buffers to be alloc'ed by mwalloc() before called. They will automatically alloc a shared memory buffer and copy over.

In the mwattach() call you can set a flag MWFASTPATH or MWSAFEPATH (default). On MWSAFEPATH mwalloc() is actually mapped to malloc() anyway. You must set MWFASTPATH to actually be given a pointer to shared memory.

The above holds true only if you use IPC to attach the MidWay domain. If you use TCP/IP, mwalloc(), mwrealloc(), andmwfree() are always identical to malloc(), realloc(), and free().  

RETURN VALUES

Always a pointer to a memory location at least the size of size. Of failure we get NULL, and errno is set to ENOMEM.
 

WARNINGS

Be aware that if you alloc a buffers and hold it a long time, and you have MWFASTPATH set, you are at any give time using more shared memory buffers than with MWSAFEPATH.
Likewise, if on MWFASTPATH there are nothing to prevent you from overwriting neighboring buffers, and thus creating havoc on the whole domain. It is normal to use MWSAFEPATH during developing phases and one critical systems, and to use MWFASTPATH on speed critical applications. Of course the gain of using MWFASTPATH increases with increased buffer lengths.

The MidWay daemon mwd(1) do occasionally try a garbage collect, but only after dead processes.

If mwrealloc() is passwd a NULL pointer, it return a NULL pointer.  

EXAMPLES

 

BUGS

 

SEE ALSO

mwattach(3C), mwcall(3C), mwservice(3C), mwreply(3C), malloc(3), realloc(3), free(3)

 

STANDARDS

NONE


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUES
WARNINGS
EXAMPLES
BUGS
SEE ALSO
STANDARDS

This document was created by man2html, using the manual pages.
Time: 11:18:49 GMT, October 24, 2000