2 * mem.h - Routines to cleanup memory after use.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2002 Project Purple
12 #include "keystructs.h"
15 * packet_dup - duplicate an OpenPGP packet.
16 * @packet: The packet to duplicate.
18 * This function takes an OpenPGP packet structure and duplicates it,
19 * including the data part. It returns NULL if there is a problem
20 * allocating memory for the duplicate.
22 struct openpgp_packet *packet_dup(struct openpgp_packet *packet);
25 * packet_list_add - Adds an OpenPGP packet list to another.
26 * @list: The packet list to add to.
27 * @list_end: The end of the packet list to add to.
28 * @packet_list: The packet list to add.
30 * This function takes an OpenPGP packet list and adds it to another list,
31 * duplicating it in the process. The list to add to need not exists to
32 * begin with, in which case the function simply duplicates the supplied
35 void packet_list_add(struct openpgp_packet_list **list,
36 struct openpgp_packet_list **list_end,
37 struct openpgp_packet_list *packet_list);
40 * free_packet - free the memory used by an OpenPGP packet.
41 * @packet: The packet to free.
43 * Takes an OpenPGP packet structure and frees the memory used by it,
44 * including the data part.
46 void free_packet(struct openpgp_packet *packet);
49 * free_packet_list - free the memory used by an OpenPGP packet list.
50 * @packet_list: The packet list to free.
52 * Takes an OpenPGP packet list structure and frees the memory used by the
53 * packets in it and the linked list overhead.
55 void free_packet_list(struct openpgp_packet_list *packet_list);
58 * free_signedpacket_list - free an OpenPGP signed packet list.
59 * @signedpacket_list: The packet list to free.
61 * Takes an OpenPGP signed packet list structure and frees the memory used
62 * by the packets and signatures it and the linked list overhead.
64 void free_signedpacket_list(
65 struct openpgp_signedpacket_list *signedpacket_list);
68 * free_publickey - free an OpenPGP public key structure.
69 * @key: The key to free.
71 * Takes an OpenPGP key and frees the memory used by all the structures it
74 void free_publickey(struct openpgp_publickey *key);