home *** CD-ROM | disk | FTP | other *** search
-
- /* File: Eden/Kernel/MsgOps/BufferCode.c */
-
- /*
- * $Header: /u1/Eden/Kernel/MsgOps/RCS/BufferCode.v Revision 1.10 85/03/14 19:04:23 eric Exp$
- * INTERFACE: Defined by exported procedures.
- *
- * FUNCTION: Provides the Message Module Buffer Services.
- * These services consist of the management of
- * small packets of memory allocated in 4-word
- * chunks.
- *
- * IMPORTS: Eden/Source/MsgOps/Types.h,
- * Eden/ErrCodes/MMcodes.h,
- * Eden/Source/MsgOps/BufferTypes.h,
- * malloc, free,
- * Eden/Source/ProcessA/Events.h.
- *
- * EXPORTS: MMAllocateData, MMDeallocateData.
- *
- * DESIGN: Currently implemented using Almes' malloc, modified to be
- * optimal for message sizes.
- *
- *
- * $Log: /u1/Eden/Source/MsgOps/RCS/BufferCode.v $
- * Revision 1.10 85/03/14 00:00:30 eric
- * Modified trace level.
- *
- * Revision 1.9 84/11/29 19:04:23 schwartz
- * Changed all calls to malloc so they don't call HoldSigs and ReleaseSigs
- * before and after, since this is now done in (Almes' version of) malloc.
- *
- * Revision 1.8 83/10/14 17:17:09 mager
- * Changed xalloc back to malloc, and revised library malloc routine.
- *
- * Revision 1.7 83/10/14 16:35:23 mager
- * Changed calls to malloc and free with xalloc and xfree.
- *
- * Revision 1.5 83/02/25 12:14:13 cady
- * Added new trace levels.
- *
- * Revision 1.4 83/02/24 16:39:13 cady
- * Replaced conditional debug trace with dynamic trace.
- * Added conditional Kernel compilation.
- *
- * Revision 1.3 83/02/22 12:05:16 cady
- * Replaced #if Debug with #ifdef Debug.
- *
- * Revision 1.2 83/01/04 15:12:45 cady
- * Revised include file specification.
- *
- * Revision 1.1 83/01/03 10:59:40 cady
- * Initial revision
- *
- * 4-Nov-1982 Initial implementation. S. Cady
- */
-
- /****************************************************************/
- /* */
- /* Message Module Buffer Library */
- /* */
- /****************************************************************/
-
- #include "Kernel/h/system.h"
- #include "Kernel/h/mmCodes.h"
- #include "Kernel/h/mmBufTypes.h"
-
- /* Data buffer size (in bytes) increment */
-
- #define CHUNKSIZE 16
-
-
- /****************************************************************/
- /* */
- /* MMAllocateData */
- /* */
- /* MMAllocateData allocates a buffer of at least fSize bytes */
- /* and returns a pointer to the buffer. Buffers are actually */
- /* allocated in 16 byte chunks in the malloc routine. */
- /* */
- /* Possible status codes: */
- /* MMSS_Success, MMSK_NoMem, MMSF_BadRange */
- /* */
- /****************************************************************/
-
- KKStatus MMAllocateData( fSize, /* in bytes */
- /* returns */ fData
- )
- unsigned int fSize;
- char **fData;
- {
- MXTraceMsg(5, "MMAllocateData( %d )\n", fSize);
-
- if ( fSize > MAXDATASIZE)
- return MMSF_BadRange;
-
- *fData = malloc( (unsigned) fSize );
-
- if ( *fData == NULL )
- return MMSK_NoMem;
-
- MXTraceMsg(6, "%d allocated (%d bytes).\n", *fData, fSize);
-
- return MMSS_Success;
- }
-
- /****************************************************************/
- /* */
- /* MMDeallocateData */
- /* */
- /* The specified packet is released and returned to the pool */
- /* of available packets.
- /* */
- /****************************************************************/
-
- void MMDeallocateData( fSize, /* in bytes */
- fData
- )
- unsigned int fSize;
- char *fData;
- {
- MXTraceMsg(5, "MMDeallocateData( %d, %d )\n", fSize, fData);
-
- if ( fData != NULL )
- free( fData );
- }
-
- /****************************************************************/
- /* End of Message Module Buffer Library */
- /****************************************************************/
-