EDIT: I've determined one issue, and that's that the list insertions return the list. I had not been accounting for that. I am now encountering a seg fault and will work on diagnosing that.
It turns out I'm having similar trouble with printing. Again the only way I have to iterate over the list is to use the provided list_foreach(list, function) method. For some reason the following call:
Code:
list_foreach(m->data, free_matrix_data);
Works just fine; however, this:
Code:
void print_list(tMatrix m)
{
list_foreach(m->data, print_data);
//printf("Printing list data \n");
}
Does not work. The print_data method looks like:
Code:
void print_data(tMatrixData md)
{
printf("Calling print_data \n");
printf("Value: %i \n", (int)md->value);
printf("Row: %i \n", md->row);
printf("Column: %i \n", md->column);
}
I have put prints into the free_matrix_data function as well, and it does get called.
The entire tList header looks like:
Code:
/* list.h */
#ifndef _LIST
#define _LIST
typedef struct sList *tList;
/* exported list functions */
tList list_copy (tList);
void *list_find(tList, void*, int(*compare)());
void *list_first(tList);
void list_foreach(tList, void (*f)());
void list_foreach1(tList, void (*f)(), void*);
void list_foreach2(tList, void (*f)(), void*, void*);
void list_foreach3(tList, void (*f)(), void*, void*, void*);
void list_foreach4(tList, void (*f)(), void*, void*, void*, void*);
void list_free(tList);
tList list_initialize();
tList list_insert_end(tList, void*);
tList list_insert_beginning(tList, void*);
tList list_insert_in_order(tList, void*, int (*compare)());
int list_isempty(tList);
int list_length(tList);
int list_member(tList, void*, int (*compare)());
void* list_remove(tList, void*, int (*compare)());
void* list_remove_first(tList);
#define list_remove_any(l) list_remove_first(l)
int tracer;
void list_foreach_pair(tList, tList, void (*f)());
void list_foreach_pair1(tList, tList, void (*f)(), void *);
void list_foreach_pair2(tList, tList, void (*f)(), void *, void*);
void list_foreach_triple1(tList, tList, tList, void (*f)(), void*);
void list_foreach_triple2(tList, tList, tList, void (*f)(), void*, void*);
#endif