home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / vopl / glvopl.lha / glvopl / src / savestr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-13  |  423 b   |  31 lines

  1. #include "vopl.h"
  2.  
  3. /*
  4.  * savestr
  5.  *
  6.  *    Save a string of goddam characters somewhere
  7.  */
  8. char *
  9. savestr(old, string)
  10.     char    *old, *string;
  11. {
  12.     char    *p;
  13.  
  14.     if (string == (char *)NULL)
  15.         return ((char *)NULL);
  16.  
  17.     p = old;
  18.  
  19.     if (p != (char *)NULL) {
  20.         if (strlen(string) > strlen(p)) {
  21.             free(p);
  22.             p = (char *)malloc(strlen(string) + 1);
  23.         }
  24.     } else
  25.         p = (char *)malloc(strlen(string) + 1);
  26.  
  27.     strcpy(p, string);
  28.  
  29.     return(p);
  30. }
  31.