home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * KeySupport.c ---------- Keymacro support routines.
- *
- * Author ---------------- Olaf Barthel, MXM
- * Brabeckstrasse 35
- * D-3000 Hannover 71
- *
- * KeyMacro © Copyright 1990 by MXM; Executable program,
- * documentation and source code are shareware. If you like
- * this program a small donation will entitle you to receive
- * updates and new programs from MXM.
- *
- ****************************************************************************/
-
- /* AllocRem():
- *
- * Allocate public memory and keep track of its size.
- */
-
- VOID *
- AllocRem(LONG ByteSize,LONG Requirements)
- {
- LONG *MemoryBlock = NULL;
- LONG RemSize = ByteSize + sizeof(LONG);
-
- if(ByteSize > 0)
- MemoryBlock = (LONG *)AllocMem(RemSize,Requirements);
-
- if(MemoryBlock)
- *MemoryBlock++ = RemSize;
-
- return((VOID *)MemoryBlock);
- }
-
- /* FreeRem():
- *
- * Free a tracked portion of memory.
- */
-
- VOID *
- FreeRem(LONG *MemoryBlock)
- {
- if(MemoryBlock--)
- FreeMem(MemoryBlock,*MemoryBlock);
-
- return(NULL);
- }
-
- /* SendMacroMsg(scm_Msg,scm_Port):
- *
- * Post a cloned macro message to a MsgPort.
- */
-
- VOID *
- SendMacroMsg(struct MacroMessage *scm_Msg,struct MsgPort *scm_Port)
- {
- struct MacroMessage *scm_TempMsg;
-
- if(scm_TempMsg = (struct MacroMessage *)AllocRem(sizeof(struct MacroMessage),MEMF_PUBLIC | MEMF_CLEAR))
- {
- CopyMem(scm_Msg,scm_TempMsg,sizeof(struct MacroMessage));
-
- scm_TempMsg -> mm_Message . mn_Node . ln_Name = (char *)scm_TempMsg;
- scm_TempMsg -> mm_Message . mn_ReplyPort = NULL;
- scm_TempMsg -> mm_Message . mn_Length = sizeof(struct MacroMessage);
-
- PutMsg(scm_Port,(struct Message *)scm_TempMsg);
- }
-
- return((VOID *)scm_TempMsg);
- }
-