home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / me34src.zip / me3 / util / savestr.c < prev    next >
C/C++ Source or Header  |  1995-01-14  |  414b  |  16 lines

  1. /* savestr.c:  Save a string by malloc()ing space and coping the string.
  2.  * Returns a pointer to the malloc()ed string.
  3.  * This is a "black box" copy of a routine in Microsoft C.
  4.  * C Durland    Public Domain
  5.  */
  6.  
  7. #include "const.h"
  8.  
  9. char *savestr(str) char *str;    /* malloc str and save it */
  10. {
  11.   char *ptr, *malloc(), *strcpy();
  12.  
  13.   if ((ptr = malloc(strlen(str)+1)) == NULL) return NULL;
  14.   return strcpy(ptr,str);
  15. }
  16.