diff --git a/lib/hooks/jitter_calc.cpp b/lib/hooks/jitter_calc.cpp index e9692ff21..6408e971b 100644 --- a/lib/hooks/jitter_calc.cpp +++ b/lib/hooks/jitter_calc.cpp @@ -75,10 +75,10 @@ public: ~JitterCalcHook() { - delete jitter_val; - delete delay_series; - delete moving_avg; - delete moving_var; + delete[] jitter_val; + delete[] delay_series; + delete[] moving_avg; + delete[] moving_var; } /** diff --git a/lib/nodes/ngsi.cpp b/lib/nodes/ngsi.cpp index 9073d6a85..f1379a8d8 100644 --- a/lib/nodes/ngsi.cpp +++ b/lib/nodes/ngsi.cpp @@ -662,7 +662,6 @@ char * ngsi_print(struct vnode *n) int ngsi_start(struct vnode *n) { struct ngsi *i = (struct ngsi *) n->_vd; - int ret; i->in.curl = curl_easy_init(); i->out.curl = curl_easy_init(); @@ -696,14 +695,14 @@ int ngsi_start(struct vnode *n) if (i->create) { json_t *json_entity = ngsi_build_entity(n, nullptr, 0, NGSI_ENTITY_ATTRIBUTES | NGSI_ENTITY_METADATA); - ret = ngsi_request_context_update(i->out.curl, i->endpoint, "APPEND", json_entity); + int ret = ngsi_request_context_update(i->out.curl, i->endpoint, "APPEND", json_entity); if (ret) throw RuntimeError("Failed to create NGSI context for node {}", node_name(n)); json_decref(json_entity); } - return ret; + return 0; } int ngsi_stop(struct vnode *n) diff --git a/lib/sample.cpp b/lib/sample.cpp index 420d78eef..4f360cff6 100644 --- a/lib/sample.cpp +++ b/lib/sample.cpp @@ -66,13 +66,11 @@ struct sample * sample_alloc_mem(int capacity) { size_t sz = SAMPLE_LENGTH(capacity); - char *b = new char[sz]; - if (!b) + auto *s = (struct sample *) new char[sz]; + if (!s) throw MemoryAllocationError(); - memset(b, 0, sz); - - struct sample *s = (struct sample *) b; + memset((void *) s, 0, sz); s->pool_off = SAMPLE_NON_POOL; diff --git a/src/villas-hook.cpp b/src/villas-hook.cpp index bf18f8276..19ed71d51 100644 --- a/src/villas-hook.cpp +++ b/src/villas-hook.cpp @@ -191,15 +191,11 @@ check: if (optarg == endptr) int ret, recv, sent; struct format_type *ft; - struct sample **smps; + struct sample *smps[cnt]; if (cnt < 1) throw RuntimeError("Vectorize option must be greater than 0"); - smps = new struct sample*[cnt]; - if (!smps) - throw MemoryAllocationError(); - ret = pool_init(&p, 10 * cnt, SAMPLE_LENGTH(DEFAULT_SAMPLE_LENGTH)); if (ret) throw RuntimeError("Failed to initilize memory pool"); @@ -301,8 +297,6 @@ stop: sent = io_print(&io, smps, send); sample_free_many(smps, cnt); - delete smps; - ret = pool_destroy(&p); if (ret) throw RuntimeError("Failed to destroy memory pool");