home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / Watcher / strsave.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-14  |  435 b   |  30 lines

  1. /*
  2.    strsave: save a string in a malloc'd area.  Return a pointer to the
  3.    string.
  4.  
  5.    Kenneth Ingham
  6.  
  7.    Copyright (C) the University of New Mexico
  8. */
  9.  
  10. #include "defs.h"
  11.  
  12. char *
  13. strsave(s)
  14. char *s;
  15. {
  16.     return strcpy(xmalloc((unsigned)strlen(s)+1), s);
  17. }
  18.  
  19. /*
  20.    note that in strnsave we allocate enough space to put a null at the
  21.    end. 
  22. */
  23. char *
  24. strnsave(s,n)
  25. char *s;
  26. unsigned int n;
  27. {
  28.     return strncpy(xmalloc(n+1), s, (int)n);
  29. }
  30.