cscvs to tla changeset 39
[onak.git] / mem.h
1 /*
2  * mem.h - Routines to cleanup memory after use.
3  *
4  * Jonathan McDowell <noodles@earth.li>
5  *
6  * Copyright 2002 Project Purple
7  */
8
9 #ifndef __MEM_H_
10 #define __MEM_H_
11
12 #include "keystructs.h"
13 #include "stats.h"
14
15 /**
16  *      packet_dup - duplicate an OpenPGP packet.
17  *      @packet: The packet to duplicate.
18  *
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.
22  */
23 struct openpgp_packet *packet_dup(struct openpgp_packet *packet);
24
25 /**
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.
30  *
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
34  *      list.
35  */
36 void packet_list_add(struct openpgp_packet_list **list,
37                 struct openpgp_packet_list **list_end,
38                 struct openpgp_packet_list *packet_list);
39
40 /**
41  *      free_packet - free the memory used by an OpenPGP packet.
42  *      @packet: The packet to free.
43  *
44  *      Takes an OpenPGP packet structure and frees the memory used by it,
45  *      including the data part.
46  */
47 void free_packet(struct openpgp_packet *packet);
48
49 /**
50  *      free_packet_list - free the memory used by an OpenPGP packet list.
51  *      @packet_list: The packet list to free.
52  *
53  *      Takes an OpenPGP packet list structure and frees the memory used by the
54  *      packets in it and the linked list overhead.
55  */
56 void free_packet_list(struct openpgp_packet_list *packet_list);
57
58 /**
59  *      free_signedpacket_list - free an OpenPGP signed packet list.
60  *      @signedpacket_list: The packet list to free.
61  *
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.
64  */
65 void free_signedpacket_list(
66                 struct openpgp_signedpacket_list *signedpacket_list);
67
68 /**
69  *      free_publickey - free an OpenPGP public key structure.
70  *      @key: The key to free.
71  *
72  *      Takes an OpenPGP key and frees the memory used by all the structures it
73  *      contains.
74  */
75 void free_publickey(struct openpgp_publickey *key);
76
77 /**
78  *      free_statskey - free an stats key structure.
79  *      @key: The key to free.
80  *
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.
84  */
85 void free_statskey(struct stats_key *key);
86
87 #endif /* __MEM_H_ */