summaryrefslogtreecommitdiffstats
path: root/ListItem.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2012-12-05 15:12:20 +0000
committerHisham Muhammad <hisham@gobolinux.org>2012-12-05 15:12:20 +0000
commit00b324bfc162030b575e03795dcfcaac56bd0b4d (patch)
treefbaada243839b0b67351856e2d02a2e8184bf65f /ListItem.c
parent2a73405cd060b543d56987650327b18078a137d7 (diff)
Changes in object model: separate class objects to store vtable. Also, nicer UTF-8 display of big numbers.
Diffstat (limited to 'ListItem.c')
-rw-r--r--ListItem.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/ListItem.c b/ListItem.c
index af50ca95..677707f0 100644
--- a/ListItem.c
+++ b/ListItem.c
@@ -26,12 +26,6 @@ typedef struct ListItem_ {
}*/
-#ifdef DEBUG
-char* LISTITEM_CLASS = "ListItem";
-#else
-#define LISTITEM_CLASS NULL
-#endif
-
static void ListItem_delete(Object* cast) {
ListItem* this = (ListItem*)cast;
free(this->value);
@@ -49,11 +43,13 @@ static void ListItem_display(Object* cast, RichString* out) {
RichString_write(out, CRT_colors[DEFAULT_COLOR], this->value/*buffer*/);
}
+ObjectClass ListItem_class = {
+ .display = ListItem_display,
+ .delete = ListItem_delete
+};
+
ListItem* ListItem_new(const char* value, int key) {
- ListItem* this = malloc(sizeof(ListItem));
- Object_setClass(this, LISTITEM_CLASS);
- ((Object*)this)->display = ListItem_display;
- ((Object*)this)->delete = ListItem_delete;
+ ListItem* this = AllocThis(ListItem);
this->value = strdup(value);
this->key = key;
return this;

© 2014-2024 Faster IT GmbH | imprint | privacy policy