Update Debian Vcs-* fields to point to git repository
[onak.git] / mem.h
1 /*
2  * mem.h - Routines to cleanup memory after use.
3  *
4  * Copyright 2002-2004,2007 Jonathan McDowell <noodles@earth.li>
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 51
17  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __MEM_H_
21 #define __MEM_H_
22
23 #include "keystructs.h"
24 #include "stats.h"
25
26 /**
27  *      packet_dup - duplicate an OpenPGP packet.
28  *      @packet: The packet to duplicate.
29  *
30  *      This function takes an OpenPGP packet structure and duplicates it,
31  *      including the data part. It returns NULL if there is a problem
32  *      allocating memory for the duplicate.
33  */
34 struct openpgp_packet *packet_dup(struct openpgp_packet *packet);
35
36 /**
37  *      packet_list_add - Adds an OpenPGP packet list to another.
38  *      @list: The packet list to add to.
39  *      @list_end: The end of the packet list to add to.
40  *      @packet_list: The packet list to add.
41  *
42  *      This function takes an OpenPGP packet list and adds it to another list,
43  *      duplicating it in the process. The list to add to need not exists to
44  *      begin with, in which case the function simply duplicates the supplied
45  *      list.
46  */
47 void packet_list_add(struct openpgp_packet_list **list,
48                 struct openpgp_packet_list **list_end,
49                 struct openpgp_packet_list *packet_list);
50
51 /**
52  *      free_packet - free the memory used by an OpenPGP packet.
53  *      @packet: The packet to free.
54  *
55  *      Takes an OpenPGP packet structure and frees the memory used by it,
56  *      including the data part.
57  */
58 void free_packet(struct openpgp_packet *packet);
59
60 /**
61  *      free_packet_list - free the memory used by an OpenPGP packet list.
62  *      @packet_list: The packet list to free.
63  *
64  *      Takes an OpenPGP packet list structure and frees the memory used by the
65  *      packets in it and the linked list overhead.
66  */
67 void free_packet_list(struct openpgp_packet_list *packet_list);
68
69 /**
70  *      free_signedpacket_list - free an OpenPGP signed packet list.
71  *      @signedpacket_list: The packet list to free.
72  *
73  *      Takes an OpenPGP signed packet list structure and frees the memory used
74  *      by the packets and signatures it and the linked list overhead.
75  */
76 void free_signedpacket_list(
77                 struct openpgp_signedpacket_list *signedpacket_list);
78
79 /**
80  *      free_publickey - free an OpenPGP public key structure.
81  *      @key: The key to free.
82  *
83  *      Takes an OpenPGP key and frees the memory used by all the structures it
84  *      contains.
85  */
86 void free_publickey(struct openpgp_publickey *key);
87
88 /**
89  *      free_statskey - free an stats key structure.
90  *      @key: The key to free.
91  *
92  *      Takes a stats key and frees the memory used by it and the linked list
93  *      of sigs under it. Doesn't recurse into the list as it's assumed all the
94  *      objects referenced also exist in the hash.
95  */
96 void free_statskey(struct stats_key *key);
97
98 #endif /* __MEM_H_ */