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

make more use of villas::MemoryAllocationError

This commit is contained in:
Steffen Vogel 2020-07-04 22:39:15 +02:00 committed by Steffen Vogel
parent 8de965d93d
commit e81b61b4f1
4 changed files with 10 additions and 6 deletions

View file

@ -28,11 +28,14 @@
#include <netlink/route/link.h>
#include <villas/utils.hpp>
#include <villas/exceptions.hpp>
#include <villas/kernel/nl.h>
/** Singleton for global netlink socket */
static struct nl_sock *sock = nullptr;
using namespace villas;
struct nl_sock * nl_init()
{
int ret;
@ -41,7 +44,7 @@ struct nl_sock * nl_init()
/* Create connection to netlink */
sock = nl_socket_alloc();
if (!sock)
error("Failed to allocate memory");
throw MemoryAllocationError();
ret = nl_connect(sock, NETLINK_ROUTE);
if (ret)

View file

@ -70,7 +70,7 @@ int tc_netem_parse(struct rtnl_qdisc **netem, json_t *cfg)
struct rtnl_qdisc *ne = rtnl_qdisc_alloc();
if (!ne)
error("Failed to allocated memory!");
throw MemoryAllocationError();
rtnl_tc_set_kind(TC_CAST(ne), "netem");

View file

@ -21,6 +21,7 @@
*********************************************************************************/
#include <villas/utils.hpp>
#include <villas/exceptions.hpp>
#include <villas/pool.h>
#include <villas/memory.h>
#include <villas/kernel/kernel.hpp>
@ -38,9 +39,9 @@ int pool_init(struct pool *p, size_t cnt, size_t blocksz, struct memory_type *m)
void *buffer = memory_alloc_aligned(p->len, p->alignment, m);
if (!buffer)
serror("Failed to allocate memory for memory pool");
else
debug(LOG_POOL | 4, "Allocated %#zx bytes for memory pool", p->len);
throw MemoryAllocationError();
debug(LOG_POOL | 4, "Allocated %#zx bytes for memory pool", p->len);
p->buffer_off = (char*) buffer - (char*) p;

View file

@ -68,7 +68,7 @@ struct sample * sample_alloc_mem(int capacity)
char *b = new char[sz];
if (!b)
throw RuntimeError("Failed to allocate memoery");
throw MemoryAllocationError();
memset(b, 0, sz);