minor changes to handler and removed some comments from engine
This commit is contained in:
parent
bd7e3212da
commit
585768f33d
3 changed files with 25 additions and 74 deletions
|
|
@ -1,21 +1,17 @@
|
|||
#include "arc/std/handler.h"
|
||||
|
||||
#include "arc/std/errno.h"
|
||||
#include "arc/std/vector.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
struct ARC_Handler {
|
||||
ARC_Vector *data;
|
||||
ARC_Vector *trash;
|
||||
|
||||
ARC_Handler_CleanDataFn cleanfn;
|
||||
};
|
||||
|
||||
void ARC_Handler_Create(ARC_Handler **handler, ARC_Handler_CompareDataFn *compareFn, ARC_Handler_CleanDataFn cleanfn){
|
||||
void ARC_Handler_Create(ARC_Handler **handler, ARC_Vector_DestroyDataFn *destroyDataFn){
|
||||
*handler = (ARC_Handler *) malloc(sizeof(ARC_Handler));
|
||||
ARC_Vector_Create(&((*handler)->data), NULL, NULL);
|
||||
ARC_Vector_Create(&((*handler)->trash), compareFn, NULL);
|
||||
(*handler)->cleanfn = cleanfn;
|
||||
ARC_Vector_Create(&((*handler)->data) , NULL, NULL );
|
||||
ARC_Vector_Create(&((*handler)->trash), NULL, destroyDataFn);
|
||||
}
|
||||
|
||||
void ARC_Handler_Destroy(ARC_Handler *handler){
|
||||
|
|
@ -32,11 +28,6 @@ void ARC_Handler_Add(ARC_Handler *handler, void *data){
|
|||
ARC_Vector_Add(handler->data, data);
|
||||
}
|
||||
|
||||
void ARC_Handler_Remove(ARC_Handler *handler, void *data){
|
||||
ARC_Vector_Add(handler->trash, data);
|
||||
ARC_Vector_Remove(handler->data, data);
|
||||
}
|
||||
|
||||
void ARC_Handler_RemoveIndex(ARC_Handler *handler, uint32_t index){
|
||||
if(ARC_Vector_GetSize(handler->data) == 0){
|
||||
return;
|
||||
|
|
@ -54,23 +45,13 @@ void ARC_Handler_Iterate(ARC_Handler *handler, ARC_Handler_DataFn datafn){
|
|||
}
|
||||
|
||||
void ARC_Handler_Clear(ARC_Handler *handler){
|
||||
uint32_t zeroIndex = 0;
|
||||
while(ARC_Vector_GetSize(handler->data)){
|
||||
ARC_Handler_RemoveIndex(handler, zeroIndex);
|
||||
while(ARC_Vector_GetSize(handler->data) != 0){
|
||||
ARC_Handler_RemoveIndex(handler, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void ARC_Handler_Clean(ARC_Handler *handler){
|
||||
uint32_t i = 0;
|
||||
while(ARC_Vector_GetSize(handler->trash)){
|
||||
void *data = ARC_Vector_Get(handler->trash, i);
|
||||
|
||||
if(handler->cleanfn){
|
||||
handler->cleanfn(data);
|
||||
}
|
||||
|
||||
ARC_Vector_RemoveIndex(handler->trash, i);
|
||||
}
|
||||
ARC_Vector_Clear(handler->trash);
|
||||
}
|
||||
|
||||
uint32_t ARC_Handler_GetSize(ARC_Handler *handler){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue