Changeset 1363


Ignore:
Timestamp:
Apr 30, 2007, 12:28:55 AM (12 years ago)
Author:
bruno
Message:

Update for the mr_list structure to have a pointer on function to remove data allocated in the structure mr_list_elt in the data field.

Location:
branches/stable/mondo/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/include/mr_list.h

    r1361 r1363  
    2323    void *data;
    2424
     25    /* Function to unallocate memory contained in data */
     26    void (*mr_free_data)(void *data);
     27
    2528    /* The neighbours (pointers to next and previous) */
    2629    struct mr_list_elt *next;
     
    3235
    3336void mr_list_alloc(struct mr_list *list);
    34 void mr_list_alloc_elt(struct mr_list_elt *elt, void *data);
     37void mr_list_alloc_elt(struct mr_list_elt *elt, void *data, void (*mr_free_data)(void *data));
    3538void mr_list_free(struct mr_list *list);
    3639void mr_list_free_elt(struct mr_list_elt *elt);
  • branches/stable/mondo/src/lib/mr_list.c

    r1361 r1363  
    2121
    2222/* Elt of list allocation and initialization */
    23 void mr_list_alloc_elt(struct mr_list_elt *elt, void *data) {
     23void mr_list_alloc_elt(struct mr_list_elt *elt, void *data, void (*mr_free_data)(void *data)) {
    2424
    2525    elt = mr_malloc(sizeof(struct mr_list_elt));
     26    elt->mr_free_data = mr_free_data;
    2627    elt->data = (void *)data;
    2728    elt->prev = NULL;
     
    3031
    3132void mr_list_free_elt(struct mr_list_elt *elt) {
     33    elt->mr_free_data(elt->data);
    3234    mr_free(elt->data);
    3335    mr_free(elt);
Note: See TracChangeset for help on using the changeset viewer.