コード例 #1
0
ファイル: crt_malloc.c プロジェクト: giveamouse/fbmuck
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);
}
コード例 #2
0
ファイル: crt_malloc.c プロジェクト: CyberLeo/protomuck
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);
}
コード例 #3
0
ファイル: crt_malloc.c プロジェクト: giveamouse/fbmuck
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;
}
コード例 #4
0
ファイル: crt_malloc.c プロジェクト: foxbird/fuzzball
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);
}
コード例 #5
0
ファイル: crt_malloc.c プロジェクト: CyberLeo/protomuck
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);
}