diff --git a/stratum/object.cpp b/stratum/object.cpp index 1d4b63b..7537f1c 100644 --- a/stratum/object.cpp +++ b/stratum/object.cpp @@ -44,25 +44,56 @@ void object_delete(YAAMP_OBJECT *object) void object_prune(CommonList *list, YAAMP_OBJECT_DELETE_FUNC deletefunc) { list->Enter(); - for(CLI li = list->first; li; ) + for(CLI li = list->first; li && list->count > 0; ) { + CLI todel = li; YAAMP_OBJECT *object = (YAAMP_OBJECT *)li->data; li = li->next; -// if(object->deleted && object->locked) -// debuglog("object set for delete is locked\n"); + if(!object) continue; if(object->deleted && !object->lock_count) { - list->Delete(object); deletefunc(object); + todel->data = NULL; + list->Delete(todel); } else if(object->lock_count && object->unlock) object->lock_count--; } -// debuglog("still %d objects in list\n", list->count); + list->Leave(); +} + +void object_prune_debug(CommonList *list, YAAMP_OBJECT_DELETE_FUNC deletefunc) +{ + list->Enter(); + for(CLI li = list->first; li && list->count > 0; ) + { + CLI todel = li; + YAAMP_OBJECT *object = (YAAMP_OBJECT *)li->data; + li = li->next; + + if(!object) continue; + + if(object->deleted && object->lock_count) + debuglog("object set for delete is locked\n"); + + if(object->deleted && !object->lock_count) + { + deletefunc(object); + todel->data = NULL; + list->Delete(todel); + } + + else if(object->lock_count && object->unlock) + object->lock_count--; + } + + if (list->count) + debuglog("still %d objects in list\n", list->count); + list->Leave(); } @@ -70,4 +101,3 @@ void object_prune(CommonList *list, YAAMP_OBJECT_DELETE_FUNC deletefunc) - diff --git a/stratum/object.h b/stratum/object.h index db730bc..bf1febf 100644 --- a/stratum/object.h +++ b/stratum/object.h @@ -13,6 +13,7 @@ typedef void (*YAAMP_OBJECT_DELETE_FUNC)(YAAMP_OBJECT *); YAAMP_OBJECT *object_find(CommonList *list, int id, bool lock=false); void object_prune(CommonList *list, YAAMP_OBJECT_DELETE_FUNC deletefunc); +void object_prune_debug(CommonList *list, YAAMP_OBJECT_DELETE_FUNC deletefunc); void object_lock(YAAMP_OBJECT *object); void object_unlock(YAAMP_OBJECT *object);