Subversion Repositories Okuu

Rev

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

Rev 3 Rev 11
Line 1... Line 1...
1
/* $Id: util.c 3 2024-09-10 19:21:48Z nishi $ */
1
/* $Id: util.c 11 2024-09-11 10:24:20Z nishi $ */
2
 
2
 
3
#include "ok_util.h"
3
#include "ok_util.h"
4
 
4
 
5
#include <string.h>
5
#include <string.h>
6
#include <stdlib.h>
6
#include <stdlib.h>
7
 
7
 
8
char* ok_strcat(const char* a, const char* b){
8
char* ok_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* ok_strcat3(const char* a, const char* b, const char* c){
16
char* ok_strcat3(const char* a, const char* b, const char* c) {
17
	char* tmp = ok_strcat(a, b);
17
	char* tmp = ok_strcat(a, b);
18
	char* str = ok_strcat(tmp, c);
18
	char* str = ok_strcat(tmp, c);
19
	free(tmp);
19
	free(tmp);
20
	return str;
20
	return str;
21
}
21
}
22
 
22
 
23
char* ok_strdup(const char* a){
23
char* ok_strdup(const char* a) { return ok_strcat(a, ""); }
24
	return ok_strcat(a, "");
-
 
25
}
-