forked from starnakin/IronGOLEM
17 lines
222 B
Plaintext
17 lines
222 B
Plaintext
strndup(str, n)
|
|
{
|
|
local i = 0;
|
|
local out;
|
|
local size;
|
|
|
|
size = strlen(str);
|
|
if (size > n)
|
|
size = n;
|
|
out = galloc(size + 1);
|
|
if (out == 0)
|
|
return (0);
|
|
[out + size] = 0;
|
|
strncpy(out, str, size);
|
|
return (out);
|
|
}
|