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:
parent
0485ffe453
commit
84425199c9
2 changed files with 12 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Add table
Reference in a new issue