Changeset - 73285a55be12
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 16 years ago 2009-09-17 19:11:44
ohnobinki@ohnopublishing.net
distrenjob_remove() converted to dummied head
1 file changed with 13 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -60,7 +60,7 @@ struct general_info {
 
/*
 
  internally defined funcs's prototypes
 
*/
 
void distrenjob_remove(struct distrenjob **head, struct distrenjob *bj);
 
void distrenjob_remove(struct distrenjob *head, struct distrenjob *bj);
 

	
 
struct distrenjob *distrenjob_get(struct distrenjob *head, jobnum_t jobnum);
 
void distrenjob_enqueue(struct distrenjob *head, struct distrenjob *job);
 
@@ -180,7 +180,7 @@ void mortition(struct distrenjob *head, 
 

	
 
  if(isJobDone)
 
    {
 
      distrenjob_remove(&head, job);
 
      distrenjob_remove(head, job);
 
      general_info.jobs_in_queue--;
 
    }
 
}
 
@@ -253,7 +253,7 @@ void distrenjob_enqueue(struct distrenjo
 
   @arg head I may end up changing the head if job == head
 
 */
 
void change_job_priority(struct distrenjob *head, struct distrenjob *job, int new_priority){
 
  distrenjob_remove(&head, job);
 
  distrenjob_remove(head, job);
 
  job->priority = new_priority;
 
  struct distrenjob *current_job;
 
  struct distrenjob *prev_job = head;
 
@@ -375,26 +375,21 @@ struct distrenjob *distrenjob_get(struct
 

	
 
   @arg head a double pointer. the head pointer will have to be changed if distrenjob == *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 distrenjob_remove(struct distrenjob **head, struct distrenjob *bj)
 
void distrenjob_remove(struct distrenjob *head, struct distrenjob *bj)
 
{
 
  struct distrenjob *previous_distrenjob;
 

	
 
  if(bj == *head)
 
    *head = bj->next;
 
  else
 
    {
 
  for(previous_distrenjob = head;
 
      previous_distrenjob
 
	&& previous_distrenjob->next != bj; /*< stop on the distrenjob that comes before bj */
 
      previous_distrenjob = previous_distrenjob->next)
 
    /* all of the action is in the definition of the for loop itself */;
 

	
 
      for(previous_distrenjob = *head;
 
        previous_distrenjob
 
          && previous_distrenjob->next != bj; /*< stop on the distrenjob that comes before bj */
 
          previous_distrenjob = previous_distrenjob->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_distrenjob->next = bj->next;
 

	
 
      /*
 
	This removes references to bj from the linked list. I.E., we now skip bj when iterating through the list
 
       */
 
      previous_distrenjob->next = bj->next;
 
    }
 
  general_info.jobs_in_queue--;
 
}
 

	
0 comments (0 inline, 0 general)