char * CrT_string_dup(const char *s, const char *file, int line) { char *p; p = (char *) CrT_malloc(1 + strlen(s), file, line); if (p) strcpy(p, s); /* Guaranteed enough space. */ return (p); }
char * CrT_string_dup(const char *s, const char *file, int line) { char *p; p = (char *) CrT_malloc(1 + strlen(s), file, line); if (p) strcpy(p, s); return (p); }
char * CrT_alloc_string(const char *string, const char *file, int line) { char *s; /* NULL, "" -> NULL */ if (!string || !*string) return 0; if ((s = (char *) CrT_malloc(strlen(string) + 1, file, line)) == 0) { abort(); } strcpy(s, string); /* Guaranteed enough space. */ return s; }
struct shared_string * CrT_alloc_prog_string(const char *s, const char *file, int line) { struct shared_string *ss; size_t length; if (s == NULL || *s == '\0') return (NULL); length = strlen(s); if ((ss = CrT_malloc(sizeof(struct shared_string) + length, file, line)) == NULL) abort(); ss->links = 1; ss->length = length; bcopy(s, ss->data, ss->length + 1); return (ss); }
struct shared_string * CrT_alloc_prog_string(const char *s, const char *file, int line, int length, int wclength) { struct shared_string *ss; if (s == NULL || *s == '\0' || length == 0) return (NULL); if (length < 0) { length = strlen(s); } if ((ss = (struct shared_string *) CrT_malloc(sizeof(struct shared_string) + length, file, line)) == NULL) abort(); ss->links = 1; ss->length = length; ss->wclength = wclength; bcopy(s, ss->data, ss->length + 1); return (ss); }