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"
27 * packet_dup - duplicate an OpenPGP packet.
28 * @packet: The packet to duplicate.
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.
34 struct openpgp_packet *packet_dup(struct openpgp_packet *packet);
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.
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
47 void packet_list_add(struct openpgp_packet_list **list,
48 struct openpgp_packet_list **list_end,
49 struct openpgp_packet_list *packet_list);
52 * free_packet - free the memory used by an OpenPGP packet.
53 * @packet: The packet to free.
55 * Takes an OpenPGP packet structure and frees the memory used by it,
56 * including the data part.
58 void free_packet(struct openpgp_packet *packet);
61 * free_packet_list - free the memory used by an OpenPGP packet list.
62 * @packet_list: The packet list to free.
64 * Takes an OpenPGP packet list structure and frees the memory used by the
65 * packets in it and the linked list overhead.
67 void free_packet_list(struct openpgp_packet_list *packet_list);
70 * free_signedpacket_list - free an OpenPGP signed packet list.
71 * @signedpacket_list: The packet list to free.
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.
76 void free_signedpacket_list(
77 struct openpgp_signedpacket_list *signedpacket_list);
80 * free_publickey - free an OpenPGP public key structure.
81 * @key: The key to free.
83 * Takes an OpenPGP key and frees the memory used by all the structures it
86 void free_publickey(struct openpgp_publickey *key);
89 * free_statskey - free an stats key structure.
90 * @key: The key to free.
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.
96 void free_statskey(struct stats_key *key);