From 458f35241d72a3adedd9e0a66432d8268548e506 Mon Sep 17 00:00:00 2001 From: Felix Brendel Date: Mon, 10 May 2021 20:51:41 +0200 Subject: [PATCH] changes to hooks --- hooks.hpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/hooks.hpp b/hooks.hpp index 51296af..1635e5b 100644 --- a/hooks.hpp +++ b/hooks.hpp @@ -50,28 +50,28 @@ struct Lambda }; -struct Hook : Array_List> { +struct Hook { + Array_List> lambdas; Hook() { - alloc(); + lambdas.alloc(); } ~Hook () { - dealloc(); + lambdas.dealloc(); } void operator<<(Lambda f) { // FIXME(Felix): Why can I not call Array_List::append here??? Hallo? - if (count == length) { - length *= 2; - data = (Lambda*)realloc(data, length * sizeof(Lambda)); + if (lambdas.count == lambdas.length) { + lambdas.length *= 2; + lambdas.data = (Lambda*)realloc(lambdas.data, lambdas.length * sizeof(Lambda)); } - data[count] = f; - count++; + lambdas.data[lambdas.count] = f; + lambdas.count++; } void operator()() { - while(count --> 0) { - fflush(stdout); - data[count](); + while(lambdas.count --> 0) { + lambdas.data[lambdas.count](); } - count = 0; + lambdas.count = 0; } }; @@ -79,6 +79,6 @@ struct __System_Shutdown_Hook : Hook { void operator()() = delete; ~__System_Shutdown_Hook() { Hook::operator()(); - dealloc(); + lambdas.dealloc(); } } system_shutdown_hook;