OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
free_queue.c
Go to the documentation of this file.
1 #include "L1A_prototype.h"
2 #include "PGS_MODIS_35005.h"
3 #include "FP_failed_pkt_queue.h"
4 
5 
6 void free_queue (FP_QUEUE_t Q)
7 
8 /*
9 !C************************************************************************
10 
11 !Description: Disposes of the queue, releasing dynamically allocated
12  memory.
13 
14 !Input Parameters:
15  FP_QUEUE_t Q ** The FIFO queue to dispose of **
16 
17 !Output Parameters:
18  None
19 
20 !Input/Output Parameters:
21  None
22 
23 Return Values:
24  None
25 
26 Externally Defined:
27  FP_QUEUE_t (FP_failed_pkt_queue.h)
28  MODIS_E_FREE_QUEUE (PGS_MODIS_35005.h)
29  MODIS_E_NULL_POINTER (PGS_MODIS_35005.h)
30 
31 Called By:
32  level1a
33 
34 Routines Called:
35  log_fmt_msg
36 
37 !Revision History:
38  Revision 2.0 2001/01/04
39  John Seaton (seaton@ltpmail.gsfc.nasa.gov)
40  Simplified code. Removed call to is_empty.
41  Added checks for NULL input arguments.
42 
43  Revision 1.0 1997/09/15 9:55
44  Tom Johnson/GSC (johnson@ltpmail.gsfc.nasa.gov)
45  Original code development.
46 
47 !Team-unique Header:
48  This software is developed by the MODIS Science
49  Data Support Team (SDST) for the National Aeronautics
50  and Space Administration (NASA), Goddard Space Flight
51  Center (GSFC), under contract NAS5-32373.
52 
53 !References and Credits:
54  None
55 
56 !Design Notes:
57  None
58 
59 !END************************************************************************
60 */
61 
62 {
63  /***************************************************************************/
64  /* */
65  /* Declare and Initialize Local Variables */
66  /* */
67  /***************************************************************************/
68 
69  char *routine = "free_queue";
70 
71  /***************************************************************************/
72  /* */
73  /* set routine to "free_queue" (done during declaration) */
74  /* */
75  /* IF ((Q not NULL) AND (Q->head not NULL)) */
76  /* THEN */
77  /* IF (NOT(Q->head->next == Q->tail)) */
78  /* THEN */
79  /* CALL log_fmt_msg to report that the queue is not empty */
80  /* INPUTS: Status, routine, */
81  /* "There are still unwritten packets in the Failed Packets Queue" */
82  /* OUTPUTS: None */
83  /* RETURNS: None */
84  /* ENDIF */
85  /* */
86  /* Free the dynamically allocated memory for Q.head */
87  /* Free the dynamically allocated memory for Q.tail */
88  /* Free the dynamically allocated memory for Q */
89  /* ENDIF */
90  /* */
91  /***************************************************************************/
92 
93  if ((Q != NULL) && (Q->head != NULL)) {
94  if (!(Q->head->next == Q->tail))
96  "There are still unwritten packets in the Failed Packets Queue");
97 
98  free(Q->head);
99  free(Q->tail);
100  free(Q);
101  }
102 
103  /***************************************************************************/
104  /* */
105  /* ELSE */
106  /* Figure out which argument was NULL and report error in LogStatus file */
107  /* ENDELSE */
108  /* */
109  /***************************************************************************/
110 
111  else {
112  if (Q == NULL)
114  "The Q structure was NULL");
115  else
117  "The Q->head structure was NULL");
118  }
119 
120 }
#define NULL
Definition: decode_rs.h:63
void log_fmt_msg(PGSt_SMF_status code, const char *routine, const char *msg_fmt,...)
Definition: log_fmt_msg.c:6
#define MODIS_E_FREE_QUEUE
void free_queue(FP_QUEUE_t Q)
Definition: free_queue.c:6
#define MODIS_E_NULL_POINTER