mi_strndup

Allocate and duplicate a string up to n bytes.

extern (C) @nogc pure @system nothrow
char*
mi_strndup
(
const(char)* s
,
size_t n
)

Parameters

s const(char)*

string to duplicate (or NULL).

n size_t

maximum number of bytes to copy (excluding the terminating zero).

Return Value

Type: char*

a pointer to newly allocated memory initialized to string s up to the first n bytes (and always zero terminated), or NULL if either out of memory or if s is NULL.

Replacement for the standard strndup() such that mi_free() can be used on the returned result.

Meta