/*
* mem.c - Routines to cleanup memory after use.
*
- * Jonathan McDowell <noodles@earth.li>
+ * Copyright 2002-2004,2007 Jonathan McDowell <noodles@earth.li>
*
- * Copyright 2002 Project Purple
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "keystructs.h"
#include "ll.h"
-#include "log.h"
#include "mem.h"
+#include "stats.h"
/**
* packet_dup - duplicate an OpenPGP packet.
{
struct openpgp_packet *newpacket = NULL;
- log_assert(packet != NULL);
+ if (packet == NULL)
+ return NULL;
newpacket = malloc(sizeof (struct openpgp_packet));
if (newpacket != NULL) {
struct openpgp_packet_list **list_end,
struct openpgp_packet_list *packet_list)
{
- log_assert(list != NULL);
- log_assert(list_end != NULL);
-
for (; packet_list != NULL; packet_list = packet_list->next) {
ADD_PACKET_TO_LIST((*list_end),
packet_dup(packet_list->packet));
* including the data part.
*/
void free_packet(struct openpgp_packet *packet) {
- log_assert(packet != NULL);
-
if (packet->data != NULL) {
free(packet->data);
packet->data = NULL;
free_packet(key->publickey);
key->publickey = NULL;
}
- if (key->revocations != NULL) {
- free_packet_list(key->revocations);
- key->revocations = NULL;
+ if (key->sigs != NULL) {
+ free_packet_list(key->sigs);
+ key->sigs = NULL;
}
if (key->uids != NULL) {
free_signedpacket_list(key->uids);
key = nextkey;
}
}
-
-/**
- * free_statskey - free an stats key structure.
- * @key: The key to free.
- *
- * Takes a stats key and frees the memory used by it and the linked list
- * of sigs under it. Doesn't recurse into the list as it's assumed all the
- * objects referenced also exist in the hash.
- */
-void free_statskey(struct stats_key *key)
-{
- if (key != NULL) {
- if (key->sigs != NULL) {
- llfree(key->sigs, NULL);
- key->sigs = NULL;
- }
- if (key->signs != NULL) {
- llfree(key->signs, NULL);
- key->signs = NULL;
- }
- free(key);
- }
-}