aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-04-05 23:37:39 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-07 00:22:01 -0300
commit967fb1aca6ea9c3d3046ccd6b9fcf0f88d6999ac (patch)
tree886a553c1f5ea139fec7600803562aa11edcfe2a /src/lib
parentfac85c17248ab8c371fb311c1dd4bc1b2a7520cf (diff)
downloadrneovim-967fb1aca6ea9c3d3046ccd6b9fcf0f88d6999ac.tar.gz
rneovim-967fb1aca6ea9c3d3046ccd6b9fcf0f88d6999ac.tar.bz2
rneovim-967fb1aca6ea9c3d3046ccd6b9fcf0f88d6999ac.zip
Reimplement the event queue in event.c using klist.h
- Add a new macro to klist.h: kl_empty() The whole point of abstract data structures is to avoid reimplementing common actions. The emptiness test seems to be such an action. - Add a new function attribute to func_attr.h: FUNC_ATTR_UNUSED Some of the many functions created by the macros in klist.h may end up not being used. Unused functions cause compilation errors as we compile with -Werror. To mark those functions as possibly unused we can use the FUNC_ATTR_UNUSED now. - Pass `Event` by value `Event` is such a small struct that I don't think we should allocate heap space and pass it by reference. Let's use the stack and memory cache in our favor passing it by value.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/klist.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/klist.h b/src/lib/klist.h
index bb60449915..f8b16ea9fa 100644
--- a/src/lib/klist.h
+++ b/src/lib/klist.h
@@ -26,8 +26,10 @@
#ifndef _AC_KLIST_H
#define _AC_KLIST_H
+#include <stdbool.h>
#include <stdlib.h>
+#include "func_attr.h"
#include "memory.h"
#define KMEMPOOL_INIT(name, kmptype_t, kmpfree_f) \
@@ -84,6 +86,8 @@
kl->head->next = 0; \
return kl; \
} \
+ static inline void kl_destroy_##name(kl_##name##_t *kl) \
+ FUNC_ATTR_UNUSED; \
static inline void kl_destroy_##name(kl_##name##_t *kl) { \
kl1_##name *p; \
for (p = kl->head; p != kl->tail; p = p->next) \
@@ -119,5 +123,6 @@
#define kl_destroy(name, kl) kl_destroy_##name(kl)
#define kl_pushp(name, kl) kl_pushp_##name(kl)
#define kl_shift(name, kl, d) kl_shift_##name(kl, d)
+#define kl_empty(kl) ((kl)->size == 0)
#endif