"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libsn/sn-list.c" between
xfe-1.42.tar.gz and xfe-1.43.tar.gz

About: Xfe (X File Explorer) is a file manager and browser (using the FOX toolkit).

sn-list.c  (xfe-1.42):sn-list.c  (xfe-1.43)
skipping to change at line 31 skipping to change at line 31
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
#include "sn-list.h" #include "sn-list.h"
#include "sn-internals.h" #include "sn-internals.h"
typedef struct SnListNode typedef struct SnListNode
{ {
void *data; void *data;
struct SnListNode *next; struct SnListNode *next;
} SnListNode; } SnListNode;
struct SnList struct SnList
{ {
SnListNode *head; SnListNode *head;
}; };
static SnListNode* static SnListNode*
sn_list_node_alloc (void) sn_list_node_alloc (void)
{ {
return sn_new0 (SnListNode, 1); return sn_new0 (SnListNode, 1);
} }
SnList* SnList*
sn_list_new (void) sn_list_new (void)
{ {
SnList *list; SnList *list;
list = sn_new (SnList, 1); list = sn_new (SnList, 1);
list->head = NULL; list->head = NULL;
return list; return list;
} }
void void
sn_list_free (SnList *list) sn_list_free (SnList *list)
{ {
SnListNode *node; SnListNode *node;
node = list->head; node = list->head;
while (node != NULL) while (node != NULL)
{ {
SnListNode *next = node->next; SnListNode *next = node->next;
sn_free (node); sn_free (node);
node = next; node = next;
} }
sn_free (list); sn_free (list);
} }
void void
sn_list_prepend (SnList *list, sn_list_prepend (SnList *list,
void *data) void *data)
{ {
if (list->head == NULL) if (list->head == NULL)
{ {
list->head = sn_list_node_alloc (); list->head = sn_list_node_alloc ();
list->head->data = data; list->head->data = data;
} }
else else
{ {
SnListNode *node; SnListNode *node;
node = sn_list_node_alloc (); node = sn_list_node_alloc ();
node->data = data; node->data = data;
node->next = list->head; node->next = list->head;
list->head = node; list->head = node;
} }
} }
void void
sn_list_append (SnList *list, sn_list_append (SnList *list,
void *data) void *data)
{ {
if (list->head == NULL) if (list->head == NULL)
{ {
list->head = sn_list_node_alloc (); list->head = sn_list_node_alloc ();
list->head->data = data; list->head->data = data;
} }
else else
{ {
SnListNode *node; SnListNode *node;
node = list->head; node = list->head;
while (node->next != NULL) while (node->next != NULL)
node = node->next; node = node->next;
node->next = sn_list_node_alloc (); node->next = sn_list_node_alloc ();
node->next->data = data; node->next->data = data;
} }
} }
void void
sn_list_remove (SnList *list, sn_list_remove (SnList *list,
void *data) void *data)
{ {
SnListNode *node; SnListNode *node;
SnListNode *prev; SnListNode *prev;
prev = NULL; prev = NULL;
node = list->head; node = list->head;
while (node != NULL) while (node != NULL)
{ {
if (node->data == data) if (node->data == data)
{ {
if (prev) if (prev)
prev->next = node->next; prev->next = node->next;
else else
list->head = node->next; list->head = node->next;
sn_free (node); sn_free (node);
return; return;
} }
prev = node; prev = node;
node = node->next; node = node->next;
} }
} }
void void
sn_list_foreach (SnList *list, sn_list_foreach (SnList *list,
SnListForeachFunc func, SnListForeachFunc func,
void *data) void *data)
{ {
SnListNode *node; SnListNode *node;
node = list->head; node = list->head;
while (node != NULL) while (node != NULL)
{ {
SnListNode *next = node->next; /* reentrancy safety */ SnListNode *next = node->next; /* reentrancy safety */
if (!(* func) (node->data, data)) if (!(* func) (node->data, data))
return; return;
node = next; node = next;
} }
} }
sn_bool_t sn_bool_t
sn_list_empty (SnList *list) sn_list_empty (SnList *list)
{ {
return list->head == NULL; return list->head == NULL;
} }
 End of changes. 36 change blocks. 
56 lines changed or deleted 56 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)