Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://semicomplete.googlecode.com/svn/ifwm@1682 66067f7…
…3-fe4c-0410-82e9-b9c6d0c95a22
- Loading branch information
1 parent
53991da
commit 87d267e
Showing
5 changed files
with
82 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "event_list.h" | ||
|
||
/* Note: item_t is the wm_event_handler */ | ||
|
||
list_t *list_new() { | ||
list_t *list; | ||
list = malloc(sizeof(list_t)); | ||
|
||
list->max_items = 10; | ||
list->nitems = 0; | ||
list->items = malloc(list->max_items * sizeof(item_t)); | ||
} | ||
|
||
void list_free(list_t *list) { | ||
free(list->items); | ||
free(list); | ||
} | ||
|
||
void list_append(list_t *list, item_t item) { | ||
list->items[list->nitems] = item; | ||
|
||
list->nitems++; | ||
if (list->nitems == list->max_items) { | ||
list->max_items *= 2; | ||
list->items = (item_t *)realloc(list->items, list->max_items * sizeof(item_t)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef EVENT_LIST_H | ||
#define EVENT_LIST_H | ||
|
||
typedef void* item_t; | ||
|
||
typedef struct list { | ||
item_t *items; | ||
int nitems; | ||
int max_items; | ||
} list_t; | ||
|
||
list_t* list_new(); | ||
void list_free(list_t *list); | ||
void list_append(list_t *list, item_t item); | ||
|
||
#endif /* EVENT_LIST_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters