Doubly linked list in Cython
Empty Constraint

You do not allow to create an empty list.


cdef AABBList* aabb_list_create(AABB* start):



However, the pop methods don't check against the empty constraint. In fact, when popping the sole node, you end up with an error.

For instance,


 cdef AABB* aabb_list_pop_first(AABBList* lst):
        cdef AABBListItem* item = lst.first
        cdef AABB* box = item.box
        lst.first = item.next     // &lt;- if item.next is NULL
        lst.first.prev = NULL     // &lt;- lst.first will be NULL, and .prev is an error
        free(item)
        lst.length -= 1
        return box



Single Remaining Item after Pop

Furthermore, when after pop a single item remains, it should be set as both first and last on the list.