File: free_memory.c

package info (click to toggle)
garlic 1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,516 kB
  • sloc: ansic: 52,465; makefile: 2,254
file content (128 lines) | stat: -rw-r--r-- 3,751 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* Copyright (C) 2000 Damir Zucic */

/*=============================================================================

				free_memory.c

Purpose:
	Free storage used for pixmaps and other data.

Input:
	(1) Pointer to GUIS structure.
	(2) Pointer to the array of MolComplexS structures.
	(3) Number of molecular complexes stored in dynamically allocated
	    memory.
	(4) Pointer to the array of NearestAtomS structures. 
	(5) Pointer to the number of pixels.

Output:
	No output (well, some memory may be freed, but this does not count).

Return value:
	No return value.

========includes:============================================================*/

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>

#include "defines.h"
#include "typedefs.h"

/*======free data storage:===================================================*/

void FreeMemory_ (GUIS *guiSP,
		  MolComplexS *mol_complexSP, int mol_complexesN,
		  NearestAtomS *nearest_atomSP, size_t *pixelsNP)
{
int		i;

/* Free pixmaps: */
if (guiSP->icon_winS.pixmapF)	 XFreePixmap (guiSP->displaySP,
					      guiSP->icon_winS.pixmapID);
if (guiSP->control_winS.pixmapF) XFreePixmap (guiSP->displaySP,
					      guiSP->control_winS.pixmapID);
if (guiSP->main_hidden_pixmapF)	 XFreePixmap (guiSP->displaySP,
					      guiSP->main_hidden_pixmapID);
if (guiSP->small_arrows_pixmapF) XFreePixmap (guiSP->displaySP,
					      guiSP->small_arrows_pixmapID);
/* Free cursors: */
if (guiSP->main_winS.cursorF)	 XFreeCursor (guiSP->displaySP,
					      guiSP->main_winS.cursorID);
if (guiSP->control_winS.cursorF) XFreeCursor (guiSP->displaySP,
					      guiSP->control_winS.cursorID);
if (guiSP->input_winS.cursorF)	 XFreeCursor (guiSP->displaySP,
					      guiSP->input_winS.cursorID);
if (guiSP->output_winS.cursorF)  XFreeCursor (guiSP->displaySP,
					      guiSP->output_winS.cursorID);

/* Free font: */
if (guiSP->main_winS.fontF)	 XFreeFont (guiSP->displaySP,
					    guiSP->main_winS.fontSP);

/* Free GC's (graphics contexts): */
if (guiSP->gca_createdF)
	{
	XFreeGC (guiSP->displaySP, guiSP->theGCA[0]);
	XFreeGC (guiSP->displaySP, guiSP->theGCA[1]);
	XFreeGC (guiSP->displaySP, guiSP->theGCA[2]);
	XFreeGC (guiSP->displaySP, guiSP->theGCA[3]);
	XFreeGC (guiSP->displaySP, guiSP->theGCA[4]);
	XFreeGC (guiSP->displaySP, guiSP->theGCA[5]);
	XFreeGC (guiSP->displaySP, guiSP->theGCA[6]);
	XFreeGC (guiSP->displaySP, guiSP->theGCA[7]);
	XFreeGC (guiSP->displaySP, guiSP->theGCA[8]);
	XFreeGC (guiSP->displaySP, guiSP->theGCA[9]);
	}

/* Free memory used to store header, atomic data, backbone and sequence: */
for (i = 0; i < mol_complexesN; i++)
	{
	if ((mol_complexSP + i)->headerS.dataP)
		{
		free ((mol_complexSP + i)->headerS.dataP);
		(mol_complexSP + i)->headerS.dataP = NULL;
		}
	if ((mol_complexSP + i)->atomSP)
		{
		free ((mol_complexSP + i)->atomSP);
		(mol_complexSP + i)->atomSP = NULL;
		(mol_complexSP + i)->atomsN = 0;
		(mol_complexSP + i)->max_atomsN = 0;
		}
	if ((mol_complexSP + i)->backboneSP)
		{
		free ((mol_complexSP + i)->backboneSP);
		(mol_complexSP + i)->backboneSP = NULL;
		(mol_complexSP + i)->c_alphaN = 0;
		}
	if ((mol_complexSP + i)->residueSP)
		{
		free ((mol_complexSP + i)->residueSP);
		(mol_complexSP + i)->residueSP = NULL;
		(mol_complexSP + i)->residuesN = 0;
		}
	if ((mol_complexSP + i)->secondary_structureP)
		{
		free ((mol_complexSP + i)->secondary_structureP);
		(mol_complexSP + i)->secondary_structureP = NULL;
		}
	}

/* Free memory used by NearestAtomS array: */
if (nearest_atomSP != NULL)
	{
	free (nearest_atomSP);
	nearest_atomSP = NULL;
	*pixelsNP = 0;
	}

}

/*===========================================================================*/