home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / dnet / dshterm1_0.lha / lib / st / string0.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-04  |  1.3 KB  |  42 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <proto/exec.h>
  4. #include <proto/dos.h>
  5. #include <st/textmessage.h>
  6. #include <st/st_proto.h>
  7.  
  8.  
  9. /**********************************************************/
  10.          void SafeFreeString0(register struct String0 *string)
  11. /**********************************************************
  12.     Free (safe) whatever the string "string0" points at
  13.  **********************************************************/
  14. {    if(string->String && (string->FreeLen > 0)) {
  15.             FreeMem(string->String, string->FreeLen);
  16.             string->String = NULL;
  17.             string->StrLen = string->FreeLen = 0;
  18.     }
  19. }
  20.  
  21. /**********************************************************/
  22. char *AllocString0(register struct String0 *string, register long length)
  23. /**********************************************************
  24.        Get some memory for the string0 buffer type
  25.      If length<1 then initialize the string0 struct
  26.  **********************************************************/
  27. {
  28.     if(length < 1) {
  29.         string->String = NULL;
  30.         string->StrLen = string->FreeLen = 0;
  31.         return(0);
  32.     }
  33.     /* Memory for the reply string */
  34.     if(! (string->String =
  35.                 AllocMem(length, MEMF_PUBLIC | MEMF_CLEAR) )) {
  36.         fpf(Output(),"*** Couldn't allocate %ld bytes\n", length);
  37.         return(NULL);
  38.     }
  39.     string->StrLen = -1; string->FreeLen = length;
  40.     return(string->String);
  41. }
  42.