2 * mem.h - Routines to cleanup memory after use.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2002 Project Purple
8 * $Id: mem.h,v 1.4 2003/06/04 20:57:11 noodles Exp $
14 #include "keystructs.h"
17 * packet_dup - duplicate an OpenPGP packet.
18 * @packet: The packet to duplicate.
20 * This function takes an OpenPGP packet structure and duplicates it,
21 * including the data part. It returns NULL if there is a problem
22 * allocating memory for the duplicate.
24 struct openpgp_packet *packet_dup(struct openpgp_packet *packet);
27 * packet_list_add - Adds an OpenPGP packet list to another.
28 * @list: The packet list to add to.
29 * @list_end: The end of the packet list to add to.
30 * @packet_list: The packet list to add.
32 * This function takes an OpenPGP packet list and adds it to another list,
33 * duplicating it in the process. The list to add to need not exists to
34 * begin with, in which case the function simply duplicates the supplied
37 void packet_list_add(struct openpgp_packet_list **list,
38 struct openpgp_packet_list **list_end,
39 struct openpgp_packet_list *packet_list);
42 * free_packet - free the memory used by an OpenPGP packet.
43 * @packet: The packet to free.
45 * Takes an OpenPGP packet structure and frees the memory used by it,
46 * including the data part.
48 void free_packet(struct openpgp_packet *packet);
51 * free_packet_list - free the memory used by an OpenPGP packet list.
52 * @packet_list: The packet list to free.
54 * Takes an OpenPGP packet list structure and frees the memory used by the
55 * packets in it and the linked list overhead.
57 void free_packet_list(struct openpgp_packet_list *packet_list);
60 * free_signedpacket_list - free an OpenPGP signed packet list.
61 * @signedpacket_list: The packet list to free.
63 * Takes an OpenPGP signed packet list structure and frees the memory used
64 * by the packets and signatures it and the linked list overhead.
66 void free_signedpacket_list(
67 struct openpgp_signedpacket_list *signedpacket_list);
70 * free_publickey - free an OpenPGP public key structure.
71 * @key: The key to free.
73 * Takes an OpenPGP key and frees the memory used by all the structures it
76 void free_publickey(struct openpgp_publickey *key);
79 * free_statskey - free an stats key structure.
80 * @key: The key to free.
82 * Takes a stats key and frees the memory used by it and the linked list
83 * of sigs under it. Doesn't recurse into the list as it's assumed all the
84 * objects referenced also exist in the hash.
86 void free_statskey(struct stats_key *key);