]> the.earth.li Git - onak.git/blob - mem.h
Fix compilation with later versions of Nettle
[onak.git] / mem.h
1 /*
2  * mem.h - Routines to cleanup memory after use.
3  *
4  * Copyright 2002-2004,2007 Jonathan McDowell <noodles@earth.li>
5  *
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.
9  *
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
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program.  If not, see <https://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __MEM_H_
20 #define __MEM_H_
21
22 #include "keystructs.h"
23 #include "stats.h"
24
25 /**
26  *      packet_dup - duplicate an OpenPGP packet.
27  *      @packet: The packet to duplicate.
28  *
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.
32  */
33 struct openpgp_packet *packet_dup(struct openpgp_packet *packet);
34
35 /**
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.
40  *
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
44  *      list.
45  */
46 void packet_list_add(struct openpgp_packet_list **list,
47                 struct openpgp_packet_list **list_end,
48                 struct openpgp_packet_list *packet_list);
49
50 /**
51  *      free_packet - free the memory used by an OpenPGP packet.
52  *      @packet: The packet to free.
53  *
54  *      Takes an OpenPGP packet structure and frees the memory used by it,
55  *      including the data part.
56  */
57 void free_packet(struct openpgp_packet *packet);
58
59 /**
60  *      free_packet_list - free the memory used by an OpenPGP packet list.
61  *      @packet_list: The packet list to free.
62  *
63  *      Takes an OpenPGP packet list structure and frees the memory used by the
64  *      packets in it and the linked list overhead.
65  */
66 void free_packet_list(struct openpgp_packet_list *packet_list);
67
68 /**
69  *      free_signedpacket_list - free an OpenPGP signed packet list.
70  *      @signedpacket_list: The packet list to free.
71  *
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.
74  */
75 void free_signedpacket_list(
76                 struct openpgp_signedpacket_list *signedpacket_list);
77
78 /**
79  *      free_publickey - free an OpenPGP public key structure.
80  *      @key: The key to free.
81  *
82  *      Takes an OpenPGP key and frees the memory used by all the structures it
83  *      contains.
84  */
85 void free_publickey(struct openpgp_publickey *key);
86
87 #endif /* __MEM_H_ */