Exemple #1
0
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);
}
Exemple #2
0
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);
}
Exemple #3
0
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;
}
Exemple #4
0
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);
}
Exemple #5
0
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);
}