2 * mem.h - Routines to cleanup memory after use.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2002 Project Purple
12 #include "keystructs.h"
16 * packet_dup - duplicate an OpenPGP packet.
17 * @packet: The packet to duplicate.
19 * This function takes an OpenPGP packet structure and duplicates it,
20 * including the data part. It returns NULL if there is a problem
21 * allocating memory for the duplicate.
23 struct openpgp_packet *packet_dup(struct openpgp_packet *packet);
26 * packet_list_add - Adds an OpenPGP packet list to another.
27 * @list: The packet list to add to.
28 * @list_end: The end of the packet list to add to.
29 * @packet_list: The packet list to add.
31 * This function takes an OpenPGP packet list and adds it to another list,
32 * duplicating it in the process. The list to add to need not exists to
33 * begin with, in which case the function simply duplicates the supplied
36 void packet_list_add(struct openpgp_packet_list **list,
37 struct openpgp_packet_list **list_end,
38 struct openpgp_packet_list *packet_list);
41 * free_packet - free the memory used by an OpenPGP packet.
42 * @packet: The packet to free.
44 * Takes an OpenPGP packet structure and frees the memory used by it,
45 * including the data part.
47 void free_packet(struct openpgp_packet *packet);
50 * free_packet_list - free the memory used by an OpenPGP packet list.
51 * @packet_list: The packet list to free.
53 * Takes an OpenPGP packet list structure and frees the memory used by the
54 * packets in it and the linked list overhead.
56 void free_packet_list(struct openpgp_packet_list *packet_list);
59 * free_signedpacket_list - free an OpenPGP signed packet list.
60 * @signedpacket_list: The packet list to free.
62 * Takes an OpenPGP signed packet list structure and frees the memory used
63 * by the packets and signatures it and the linked list overhead.
65 void free_signedpacket_list(
66 struct openpgp_signedpacket_list *signedpacket_list);
69 * free_publickey - free an OpenPGP public key structure.
70 * @key: The key to free.
72 * Takes an OpenPGP key and frees the memory used by all the structures it
75 void free_publickey(struct openpgp_publickey *key);
78 * free_statskey - free an stats key structure.
79 * @key: The key to free.
81 * Takes a stats key and frees the memory used by it and the linked list
82 * of sigs under it. Doesn't recurse into the list as it's assumed all the
83 * objects referenced also exist in the hash.
85 void free_statskey(struct stats_key *key);