Subversion Repositories MLServ

Rev

Rev 1 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 3
Line 1... Line 1...
1
/* $Id: string.c 1 2024-09-07 01:58:02Z nishi $ */
1
/* $Id: string.c 3 2024-09-24 15:50:24Z nishi $ */
2
 
2
 
3
#include "cm_string.h"
3
#include "cm_string.h"
4
 
4
 
5
#include <string.h>
5
#include <string.h>
6
#include <stdlib.h>
6
#include <stdlib.h>
7
 
7
 
8
char* cm_strcat(const char* a, const char* b){
8
char* cm_strcat(const char* a, const char* b) {
9
	char* str = malloc(strlen(a) + strlen(b) + 1);
9
	char* str = malloc(strlen(a) + strlen(b) + 1);
10
	memcpy(str, a, strlen(a));
10
	memcpy(str, a, strlen(a));
11
	memcpy(str + strlen(a), b, strlen(b));
11
	memcpy(str + strlen(a), b, strlen(b));
12
	str[strlen(a) + strlen(b)] = 0;
12
	str[strlen(a) + strlen(b)] = 0;
13
	return str;
13
	return str;
14
}
14
}
15
 
15
 
16
char* cm_strdup(const char* str){
16
char* cm_strdup(const char* str) { return cm_strcat(str, ""); }
17
	return cm_strcat(str, "");
-
 
18
}
-