# HG changeset patch # User Binki # Date 2009-07-15 13:16:53 # Node ID 9a584f11d1623950bf0677ff090042bfd04ce5e0 # Parent 8f9ccca43d053f541b401d2bfc41963f21c43b30 added and integrated blendjob_remove() diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -37,9 +37,11 @@ #include -/* internally defined funcs */ +/* + internally defined funcs's prototypes +*/ void status_report_generator(); - +void blendjob_remove(struct blendjob **head, struct blendjob *bj); // Global Vars, try to cut down on these int jobnum = 0; // The next job number to create in the queue @@ -152,14 +154,16 @@ jobnum++; // Advance the jobnumber for t /* Status Report Generator: figures out how much of the job is done, where jobnum corresponds to the job number + + blendjobs_head is a pointer to a pointer because the head of the blendjobs linked list may need to be changed by blendjob_remove */ -void status_report_generator(struct blendjob *blendjobs_head) +void status_report_generator(struct blendjob **blendjobs_head) { struct blendjob *blendjob_ptr; unsigned short workers_working; /*< used to count the total number of workers working */ unsigned int numjobs; /*< used to track number of jobs */ - blendjob_ptr = blendjobs_head; + blendjob_ptr = *blendjobs_head; workers_working = 0; numjobs = 0; @@ -214,6 +218,7 @@ void status_report_generator(struct blen /* If all frames are complete */ { blendjob_ptr->priority = 0; /*< set priority to zero to indicate job is complete */ + blendjob_remove(blendjobs_head, blendjob_ptr); /*< remove this job from the linkedlist */ general_info.total_finished_jobs++; /*< add one to the total finished jobs */ } @@ -333,6 +338,38 @@ void blend_frame_watchdog(struct blendjo } +/** + Removes a blendjob from the blendjob linkelist. + + @arg head a double pointer. the head pointer will have to be changed if blendjob == *head. Thus, make sure that the pointer points to the pointer to the head that all functions use. (I'm going to come back to this and misunderstand myself ;-)) + */ +void blendjob_remove(struct blendjob **head, struct blendjob *bj) +{ + struct blendjob *previous_blendjob; + + if(bj == *head) + *head = bj->next; + else + { + + for(previous_blendjob = *head; + previous_blendjob + && previous_blendjob->next != bj; /*< stop on the blendjob that comes before bj */ + previous_blendjob = previous_blendjob->next) + /* all of the action is in the definition of the for loop itself */; + + /* + This removes references to bj from the linked list. I.E., we now skip bj when iterating through the list + */ + previous_blendjob->next = bj->next; + } + + /* + @lordofwar: the magic deallocation of memory ;-) + */ + free(bj); +} + /* ************************** Main ************************* */