mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
added new helper function to allocate and initialize memory
This commit is contained in:
parent
ff010ba291
commit
85d23eae40
2 changed files with 14 additions and 0 deletions
|
@ -75,6 +75,9 @@ void print(enum log_level lvl, const char *fmt, ...);
|
|||
*/
|
||||
cpu_set_t to_cpu_set(int set);
|
||||
|
||||
/** Allocate and initialize memory. */
|
||||
void * alloc(size_t bytes);
|
||||
|
||||
/** Get delta between two timespec structs */
|
||||
double timespec_delta(struct timespec *start, struct timespec *end);
|
||||
|
||||
|
|
|
@ -80,6 +80,17 @@ cpu_set_t to_cpu_set(int set)
|
|||
return cset;
|
||||
}
|
||||
|
||||
void * alloc(size_t bytes)
|
||||
{
|
||||
void *p = malloc(bytes);
|
||||
if (!p)
|
||||
error("Failed to allocate memory");
|
||||
|
||||
memset(p, 0, bytes);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
double timespec_delta(struct timespec *start, struct timespec *end)
|
||||
{
|
||||
double sec = end->tv_sec - start->tv_sec;
|
||||
|
|
Loading…
Add table
Reference in a new issue