1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

added strdup() alike helper to clone objects

This commit is contained in:
Steffen Vogel 2015-10-07 09:12:56 +02:00
parent 0485ffe453
commit 84425199c9
2 changed files with 12 additions and 0 deletions

View file

@ -111,6 +111,9 @@ cpu_set_t to_cpu_set(int set);
/** Allocate and initialize memory. */
void * alloc(size_t bytes);
/** Allocate and copy memory. */
void * memdup(const void *src, size_t bytes);
/** Call quit() in the main thread. */
void die();

View file

@ -135,3 +135,12 @@ void * alloc(size_t bytes)
return p;
}
void * memdup(const void *src, size_t bytes)
{
void *dst = alloc(bytes);
memcpy(dst, src, bytes);
return dst;
}