home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_c / suplib.lzh / SUPLIB / SRC / MISC1.C < prev    next >
C/C++ Source or Header  |  1991-08-16  |  1KB  |  73 lines

  1.  
  2. /*
  3.  *  MISC1.C
  4.  *
  5.  *  General Stuff... mostly in assembly.
  6.  */
  7.  
  8. #include <local/typedefs.h>
  9. #include <exec/execbase.h>
  10. #ifdef LATTICE
  11. #include <string.h>
  12. #endif
  13.  
  14. typedef struct {
  15.     NODE     ml_Node;
  16.     uword    ml_NumEntries;
  17.     MEMENTRY ml_ME[2];
  18. } MYMEMLIST;
  19.  
  20. /*BREAKUP   gettaskdata.c   */
  21.  
  22. APTR
  23. GetTaskData(name, bytes)
  24. char *name;
  25. long bytes;
  26. {
  27.     extern EXECBASE *SysBase;
  28.     register LIST *list;
  29.     register MEMLIST *ml;
  30.  
  31.     list = &SysBase->ThisTask->tc_MemEntry;
  32.     if (ml = FindName2(list, name))
  33.     return(ml->ml_ME[0].me_Un.meu_Addr);
  34.     if (!bytes)
  35.     return(NULL);
  36.     if (!list->lh_Head)
  37.     NewList(list);
  38.     {
  39.     MYMEMLIST Ml;
  40.  
  41.     Ml.ml_NumEntries = 2;
  42.     Ml.ml_ME[0].me_Un.meu_Reqs = MEMF_PUBLIC|MEMF_CLEAR;
  43.     Ml.ml_ME[0].me_Length = bytes;
  44.     Ml.ml_ME[1].me_Un.meu_Reqs = MEMF_PUBLIC;
  45.     Ml.ml_ME[1].me_Length = strlen(name)+1;
  46.     if (ml = AllocEntry((struct MemList *)&Ml)) {
  47.         ml->ml_Node.ln_Name = (char *)ml->ml_ME[1].me_Un.meu_Addr;
  48.         strcpy(ml->ml_Node.ln_Name, name);
  49.         AddHead(list, (NODE *)ml);
  50.         return(ml->ml_ME[0].me_Un.meu_Addr);
  51.     }
  52.     }
  53.     return(NULL);
  54. }
  55.  
  56. /*BREAKUP   freetaskdata.c  */
  57.  
  58. int
  59. FreeTaskData(name)
  60. char *name;
  61. {
  62.     extern EXECBASE *SysBase;
  63.     register MEMLIST *ml;
  64.  
  65.     if (ml = FindName2(&SysBase->ThisTask->tc_MemEntry, name)) {
  66.     Remove((NODE *)ml);
  67.     FreeEntry(ml);
  68.     return(1);
  69.     }
  70.     return(0);
  71. }
  72.  
  73.