2 * mem.h - Routines to cleanup memory after use.
4 * Copyright 2002-2004,2007 Jonathan McDowell <noodles@earth.li>
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.
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
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.
23 #include "keystructs.h"
26 * packet_dup - duplicate an OpenPGP packet.
27 * @packet: The packet to duplicate.
29 * This function takes an OpenPGP packet structure and duplicates it,
30 * including the data part. It returns NULL if there is a problem
31 * allocating memory for the duplicate.
33 struct openpgp_packet *packet_dup(struct openpgp_packet *packet);
36 * packet_list_add - Adds an OpenPGP packet list to another.
37 * @list: The packet list to add to.
38 * @list_end: The end of the packet list to add to.
39 * @packet_list: The packet list to add.
41 * This function takes an OpenPGP packet list and adds it to another list,
42 * duplicating it in the process. The list to add to need not exists to
43 * begin with, in which case the function simply duplicates the supplied
46 void packet_list_add(struct openpgp_packet_list **list,
47 struct openpgp_packet_list **list_end,
48 struct openpgp_packet_list *packet_list);
51 * free_packet - free the memory used by an OpenPGP packet.
52 * @packet: The packet to free.
54 * Takes an OpenPGP packet structure and frees the memory used by it,
55 * including the data part.
57 void free_packet(struct openpgp_packet *packet);
60 * free_packet_list - free the memory used by an OpenPGP packet list.
61 * @packet_list: The packet list to free.
63 * Takes an OpenPGP packet list structure and frees the memory used by the
64 * packets in it and the linked list overhead.
66 void free_packet_list(struct openpgp_packet_list *packet_list);
69 * free_signedpacket_list - free an OpenPGP signed packet list.
70 * @signedpacket_list: The packet list to free.
72 * Takes an OpenPGP signed packet list structure and frees the memory used
73 * by the packets and signatures it and the linked list overhead.
75 void free_signedpacket_list(
76 struct openpgp_signedpacket_list *signedpacket_list);
79 * free_publickey - free an OpenPGP public key structure.
80 * @key: The key to free.
82 * Takes an OpenPGP key and frees the memory used by all the structures it
85 void free_publickey(struct openpgp_publickey *key);
88 * free_statskey - free an stats key structure.
89 * @key: The key to free.
91 * Takes a stats key and frees the memory used by it and the linked list
92 * of sigs under it. Doesn't recurse into the list as it's assumed all the
93 * objects referenced also exist in the hash.
95 void free_statskey(struct stats_key *key);