forked from enlightenment/efl
+eina_memdup
for those times when three lines of code should be one @feature
This commit is contained in:
parent
5cda4c1eb5
commit
10d8199b2f
|
@ -662,3 +662,16 @@ eina_str_toupper(char **str)
|
|||
for (p = *str; (*p); p++)
|
||||
*p = toupper((unsigned char)(*p));
|
||||
}
|
||||
|
||||
EAPI unsigned char *
|
||||
eina_memdup(unsigned char *mem, size_t size, Eina_Bool terminate)
|
||||
{
|
||||
unsigned char *ret;
|
||||
|
||||
terminate = !!terminate;
|
||||
ret = malloc(size + terminate);
|
||||
memcpy(ret, mem, size);
|
||||
if (terminate)
|
||||
ret[size] = 0;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -345,6 +345,15 @@ static inline size_t eina_str_join(char *dst, size_t size, char sep, const char
|
|||
|
||||
static inline size_t eina_strlen_bounded(const char *str, size_t maxlen) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief memory duplication function with optional termination for strings
|
||||
* @param mem The memory to copy
|
||||
* @param size The size of @p mem
|
||||
* @param terminate If true, the returned memory will be nul terminated with '\0'
|
||||
* @return the copied memory, must be freed
|
||||
* @since 1.13
|
||||
*/
|
||||
EAPI unsigned char *eina_memdup(unsigned char *mem, size_t size, Eina_Bool terminate);
|
||||
#include "eina_inline_str.x"
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue