CoreFW  Diff

Differences From Artifact [cebb101511]:

To Artifact [3b8850abd4]:


42
43
44
45
46
47
48






















49
50
51
52
53
54
55
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







char*
cfw_strdup(const char *s)
{
	char *copy;
	size_t len;

	len = strlen(s);

	if ((copy = malloc(len + 1)) == NULL) {
		errno = ENOMEM;
		return NULL;
	}

	memcpy(copy, s, len);
	copy[len] = 0;

	return copy;
}

char*
cfw_strndup(const char *s, size_t max)
{
	char *copy;
	size_t len;

	len = strlen(s);

	if (len > max)
		len = max;

	if ((copy = malloc(len + 1)) == NULL) {
		errno = ENOMEM;
		return NULL;
	}

	memcpy(copy, s, len);