home *** CD-ROM | disk | FTP | other *** search
- /* C.Strdup: save a string on the heap; return pointer to it */
-
- #include <stdio.h>
- #include <string.h>
- #include <stddef.h>
- #include <stdlib.h>
- #include "utils.h"
-
- char *strdup (const char *str)
- {
- char *p = malloc(strlen(str)+1);
-
- if (p == NULL)
- {
- fprintf(stderr,"Not enough memory to save string\n");
- exit(1);
- }
-
- return (strcpy(p,str));
- }
-