diff --git a/lib/kernel/nl.cpp b/lib/kernel/nl.cpp index cd072b1d8..a0f42e806 100644 --- a/lib/kernel/nl.cpp +++ b/lib/kernel/nl.cpp @@ -28,11 +28,14 @@ #include #include +#include #include /** 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) diff --git a/lib/kernel/tc_netem.cpp b/lib/kernel/tc_netem.cpp index 6e17f830d..15c0be5f1 100644 --- a/lib/kernel/tc_netem.cpp +++ b/lib/kernel/tc_netem.cpp @@ -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"); diff --git a/lib/pool.cpp b/lib/pool.cpp index 3fe018ed6..cdc7f39ba 100644 --- a/lib/pool.cpp +++ b/lib/pool.cpp @@ -21,6 +21,7 @@ *********************************************************************************/ #include +#include #include #include #include @@ -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; diff --git a/lib/sample.cpp b/lib/sample.cpp index 500192f7b..420d78eef 100644 --- a/lib/sample.cpp +++ b/lib/sample.cpp @@ -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);