Golem  v0.1.1
Generic Operating system Libraries for Embedded Multitasking
 All Data Structures Files Functions Variables Pages
example_glm_list.c
/*
* Example using glm_list.h in combination with glm_object.h
*
* This example assumes the caller has already created an object using
* malloc() or equivalent for adding to the list named 'my_obj' in this
* example. It is also assumed that the caller has already obtained a
* heap-ID (using glm_heap.h) named 'my_heap_id' in this example.
* which is named
*/
#include "glm_list.h"
// Declare and initialize the required pointer-variables
list_t * my_list = NULL;
list_item_t * my_item = NULL;
typedef struct
{
char *firstname;
char *lastname;
} my_object_t;
// Create an instance of the list to which we want add my_obj and maybe other
// objects.
my_list = list_create(heap_id);
// Proceed if successful
if (NULL != my_list)
{
// Create an object using Golem's heap functionality
my_object = heap_malloc(heap_id, sizeof(my_object_t));
// Now create a new list item holding the alarm
my_item = list_item_create(my_list, (void* my_object));
// Proceed if successful
if (NULL != my_item)
{
// Append object to the list
my_item = list_append(my_list, my_item);
}
}