2019-01-29 12:48:01 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
char *strdup(const char *s)
|
|
|
|
{
|
|
|
|
size_t sz = strlen(s) + 1;
|
|
|
|
char *d = malloc(sz);
|
2019-04-12 03:36:08 +02:00
|
|
|
if (d)
|
|
|
|
memcpy(d, s, sz);
|
2019-01-29 12:48:01 +01:00
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *strconcat(const char *s1, const char *s2)
|
|
|
|
{
|
|
|
|
size_t sz_1 = strlen(s1);
|
|
|
|
size_t sz_2 = strlen(s2);
|
|
|
|
char *d = malloc(sz_1 + sz_2 + 1);
|
2019-04-12 03:36:08 +02:00
|
|
|
if (d) {
|
|
|
|
memcpy(d, s1, sz_1);
|
|
|
|
memcpy(d + sz_1, s2, sz_2 + 1);
|
|
|
|
}
|
2019-01-29 12:48:01 +01:00
|
|
|
return d;
|
|
|
|
}
|