Remove stray exit() in the regress test.
[oweals/opkg-lede.git] / libopkg / active_list.c
index 1d38d8d6bc7c09e37c64dbbd02af2452f5ea2a42..69ac1d11c0df5fa9b5b819277d319cab92dc1961 100644 (file)
@@ -2,7 +2,7 @@
 
    Tick Chen <tick@openmoko.com>
 
-   Copyright (C) 2008 Openmoko Inc. 
+   Copyright (C) 2008 Openmoko Inc.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "libbb/libbb.h"
 
 void active_list_init(struct active_list *ptr) {
     INIT_LIST_HEAD(&ptr->node);
@@ -29,11 +30,11 @@ void active_list_init(struct active_list *ptr) {
 }
 
 /**
- */ 
+ */
 struct active_list * active_list_next(struct active_list *head, struct active_list *ptr) {
     struct active_list *next=NULL;
     if ( !head ) {
-        fprintf(stderr, "active_list_next head = %p, ptr = %p invalid value!!\n", head, ptr);
+        opkg_msg(ERROR, "Internal error: head=%p, ptr=%p\n", head, ptr);
         return NULL;
     }
     if ( !ptr )
@@ -46,7 +47,7 @@ struct active_list * active_list_next(struct active_list *head, struct active_li
         return ptr->depended;
     }
     while ( next->depend.next != &next->depend ) {
-        next = list_entry(next->depend.next, struct active_list, node); 
+        next = list_entry(next->depend.next, struct active_list, node);
     }
     return next;
 }
@@ -55,7 +56,7 @@ struct active_list * active_list_next(struct active_list *head, struct active_li
 struct active_list * active_list_prev(struct active_list *head, struct active_list *ptr) {
     struct active_list *prev=NULL;
     if ( !head ) {
-        fprintf(stderr, "active_list_prev head = %p, ptr = %p invalid value!!\n", head, ptr);
+        opkg_msg(ERROR, "Internal error: head=%p, ptr=%p\n", head, ptr);
         return NULL;
     }
     if ( !ptr )
@@ -63,10 +64,10 @@ struct active_list * active_list_prev(struct active_list *head, struct active_li
     if ( ptr->depend.prev != &ptr->depend ) {
         prev = list_entry(ptr->depend.prev, struct active_list, node);
         return prev;
-    } 
+    }
     if ( ptr->depended  && ptr->depended != head && &ptr->depended->depend == ptr->node.prev ) {
         prev = list_entry(ptr->depended->node.prev, struct active_list, node);
-    } else 
+    } else
         prev = list_entry(ptr->node.prev, struct active_list, node);
     if ( prev == head )
         return NULL;
@@ -118,8 +119,8 @@ void active_list_add(struct active_list *head, struct active_list *node) {
     node->depended  = head;
 }
 
-struct active_list * active_list_head_new() {
-    struct active_list * head = calloc(1, sizeof(struct active_list));
+struct active_list * active_list_head_new(void) {
+    struct active_list * head = xcalloc(1, sizeof(struct active_list));
     active_list_init(head);
     return head;
 }
@@ -130,8 +131,8 @@ void active_list_head_delete(struct active_list *head) {
 }
 
 /*
- *  Using insert sort. 
- *  Note. the list should not be large, or it will be very inefficient. 
+ *  Using insert sort.
+ *  Note. the list should not be large, or it will be very inefficient.
  *
  */
 struct active_list * active_list_sort(struct active_list *head, int (*compare)(const void *, const void *)) {