Update Debian Vcs-* fields to point to git repository
[onak.git] / mem.c
diff --git a/mem.c b/mem.c
index 4a713e4ea5dec6b67fdfb8ff78a0ea22551432e9..83c63849f83b356ddfae5ab419dd8c4d17593a5e 100644 (file)
--- a/mem.c
+++ b/mem.c
@@ -1,14 +1,22 @@
 /*
  * 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.
  *
- * $Id: mem.c,v 1.6 2003/06/07 13:45:35 noodles Exp $
+ * 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, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -16,6 +24,7 @@
 #include "keystructs.h"
 #include "ll.h"
 #include "mem.h"
+#include "stats.h"
 
 /**
  *     packet_dup - duplicate an OpenPGP packet.
@@ -29,7 +38,8 @@ struct openpgp_packet *packet_dup(struct openpgp_packet *packet)
 {
        struct openpgp_packet *newpacket = NULL;
 
-       assert(packet != NULL);
+       if (packet == NULL)
+               return NULL;
 
        newpacket = malloc(sizeof (struct openpgp_packet));
        if (newpacket != NULL) {
@@ -61,9 +71,6 @@ void packet_list_add(struct openpgp_packet_list **list,
                struct openpgp_packet_list **list_end,
                struct openpgp_packet_list *packet_list)
 {
-       assert(list != NULL);
-       assert(list_end != NULL);
-
        for (; packet_list != NULL; packet_list = packet_list->next) {
                ADD_PACKET_TO_LIST((*list_end),
                                packet_dup(packet_list->packet));
@@ -83,8 +90,6 @@ void packet_list_add(struct openpgp_packet_list **list,
  *     including the data part.
  */
 void free_packet(struct openpgp_packet *packet) {
-       assert(packet != NULL);
-
        if (packet->data != NULL) {
                free(packet->data);
                packet->data = NULL;
@@ -102,8 +107,6 @@ void free_packet(struct openpgp_packet *packet) {
 void free_packet_list(struct openpgp_packet_list *packet_list) {
        struct openpgp_packet_list *nextpacket = NULL;
 
-       assert(packet_list != NULL);
-
        while (packet_list != NULL) {
                nextpacket = packet_list->next;
                if (packet_list->packet != NULL) {
@@ -125,8 +128,6 @@ void free_signedpacket_list(
                struct openpgp_signedpacket_list *signedpacket_list) {
        struct openpgp_signedpacket_list *nextpacket = NULL;
 
-       assert(signedpacket_list != NULL);
-
        while (signedpacket_list != NULL) {
                nextpacket = signedpacket_list->next;
                if (signedpacket_list->packet != NULL) {
@@ -150,17 +151,15 @@ void free_signedpacket_list(
 void free_publickey(struct openpgp_publickey *key) {
        struct openpgp_publickey *nextkey = NULL;
 
-       assert(key != NULL);
-
        while (key != NULL) {
                nextkey = key->next;
                if (key->publickey != 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);