cscvs to tla changeset 77
[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  * $Id: mem.h,v 1.4 2003/06/04 20:57:11 noodles Exp $
9  */
10
11 #ifndef __MEM_H_
12 #define __MEM_H_
13
14 #include "keystructs.h"
15
16 /**
17  *      packet_dup - duplicate an OpenPGP packet.
18  *      @packet: The packet to duplicate.
19  *
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.
23  */
24 struct openpgp_packet *packet_dup(struct openpgp_packet *packet);
25
26 /**
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.
31  *
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
35  *      list.
36  */
37 void packet_list_add(struct openpgp_packet_list **list,
38                 struct openpgp_packet_list **list_end,
39                 struct openpgp_packet_list *packet_list);
40
41 /**
42  *      free_packet - free the memory used by an OpenPGP packet.
43  *      @packet: The packet to free.
44  *
45  *      Takes an OpenPGP packet structure and frees the memory used by it,
46  *      including the data part.
47  */
48 void free_packet(struct openpgp_packet *packet);
49
50 /**
51  *      free_packet_list - free the memory used by an OpenPGP packet list.
52  *      @packet_list: The packet list to free.
53  *
54  *      Takes an OpenPGP packet list structure and frees the memory used by the
55  *      packets in it and the linked list overhead.
56  */
57 void free_packet_list(struct openpgp_packet_list *packet_list);
58
59 /**
60  *      free_signedpacket_list - free an OpenPGP signed packet list.
61  *      @signedpacket_list: The packet list to free.
62  *
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.
65  */
66 void free_signedpacket_list(
67                 struct openpgp_signedpacket_list *signedpacket_list);
68
69 /**
70  *      free_publickey - free an OpenPGP public key structure.
71  *      @key: The key to free.
72  *
73  *      Takes an OpenPGP key and frees the memory used by all the structures it
74  *      contains.
75  */
76 void free_publickey(struct openpgp_publickey *key);
77
78 /**
79  *      free_statskey - free an stats key structure.
80  *      @key: The key to free.
81  *
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.
85  */
86 void free_statskey(struct stats_key *key);
87
88 #endif /* __MEM_H_ */