[hipl-commit] [trunk] Rev 4299: Eliminate HIP_FREE / HIP_MALLOC macros.

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Thu, 15 Apr 2010 23:47:56 +0300

Committer: Diego Biurrun <diego@xxxxxxxxxx>
Date: 15/04/2010 at 23:47:56
Revision: 4299
Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Eliminate HIP_FREE / HIP_MALLOC macros.
  
  These macros were just pointless wrappers around free / malloc.

Modified:
  M  agent/connhipd.c
  M  firewall/cache.c
  M  firewall/common_hipd_msg.c
  M  firewall/conntrack.c
  M  firewall/esp_prot_fw_msg.c
  M  firewall/firewall.c
  M  firewall/firewalldb.c
  M  firewall/lsi.c
  M  firewall/proxy.c
  M  firewall/user_ipsec_fw_msg.c
  M  hipd/blind.c
  M  hipd/bos.c
  M  hipd/close.c
  M  hipd/cookie.c
  M  hipd/dht.c
  M  hipd/hadb.c
  M  hipd/hadb_legacy.c
  M  hipd/hidb.c
  M  hipd/hiprelay.c
  M  hipd/init.c
  M  hipd/input.c
  M  hipd/keymat.c
  M  hipd/maintenance.c
  M  hipd/netdev.c
  M  hipd/oppdb.c
  M  hipd/output.c
  M  hipd/update_legacy.c
  M  hipd/user_ipsec_hipd_msg.c
  M  lib/core/builder.c
  M  lib/core/builder.h
  M  lib/core/filemanip.c
  M  lib/core/hostid.c
  M  lib/tool/nlink.c
  M  test/hashtest.c

=== modified file 'agent/connhipd.c'
--- agent/connhipd.c    2010-03-18 21:15:21 +0000
+++ agent/connhipd.c    2010-04-15 20:47:19 +0000
@@ -13,6 +13,7 @@
  * @author Antti Partanen <aehparta@xxxxxxxxx>
  */
 
+#include <stdlib.h>
 #include <sys/un.h>
 #include <pthread.h>
 #include <errno.h>
@@ -345,7 +346,7 @@
         close(hip_agent_sock);
     }
     if (msg != NULL) {
-        HIP_FREE(msg);
+        free(msg);
     }
 
     hip_agent_thread_started = 0;
@@ -383,7 +384,7 @@
         close(hip_agent_sock);
     }
     if (err && msg) {
-        HIP_FREE(msg);
+        free(msg);
     }
 
     return err;

=== modified file 'firewall/cache.c'
--- firewall/cache.c    2010-04-15 17:06:57 +0000
+++ firewall/cache.c    2010-04-15 20:47:19 +0000
@@ -13,6 +13,8 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
+
 #include "cache.h"
 #include "lib/core/debug.h"
 #include "lib/core/builder.h"
@@ -33,7 +35,7 @@
     firewall_cache_hl_t *entry = NULL;
     int err = 0;
 
-    HIP_IFEL(!(entry = HIP_MALLOC(sizeof(firewall_cache_hl_t), 0)),
+    HIP_IFEL(!(entry = malloc(sizeof(firewall_cache_hl_t))),
              -ENOMEM, "No memory available for firewall database entry\n");
     memset(entry, 0, sizeof(*entry));
 out_err:

=== modified file 'firewall/common_hipd_msg.c'
--- firewall/common_hipd_msg.c  2010-04-09 16:24:44 +0000
+++ firewall/common_hipd_msg.c  2010-04-15 20:47:19 +0000
@@ -8,6 +8,8 @@
  * @author Miika Komu <miika@xxxxxx>
  */
 
+#include <stdlib.h>
+
 #include "common_hipd_msg.h"
 #include "lib/core/ife.h"
 #include "lib/core/debug.h"
@@ -72,7 +74,7 @@
 
 out_err:
     if (msg) {
-        HIP_FREE(msg);
+        free(msg);
     }
     return res;
 }

=== modified file 'firewall/conntrack.c'
--- firewall/conntrack.c        2010-04-15 16:57:50 +0000
+++ firewall/conntrack.c        2010-04-15 20:47:19 +0000
@@ -18,6 +18,7 @@
 #define _BSD_SOURCE
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include "config.h"
 #include "conntrack.h"
@@ -220,7 +221,7 @@
              -1, "Unable to verify HOST_ID mapping to src HIT\n");
 
     // init hi parameter and copy
-    HIP_IFEL(!(data->src_hi = HIP_MALLOC(len, 0)),
+    HIP_IFEL(!(data->src_hi = malloc(len)),
              -ENOMEM, "Out of memory\n");
     memcpy(data->src_hi, host_id, len);
 

=== modified file 'firewall/esp_prot_fw_msg.c'
--- firewall/esp_prot_fw_msg.c  2010-04-09 16:24:44 +0000
+++ firewall/esp_prot_fw_msg.c  2010-04-15 20:47:19 +0000
@@ -10,6 +10,7 @@
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
  */
 
+#include <stdlib.h>
 #include <netinet/udp.h>
 
 #include "lib/core/debug.h"
@@ -48,7 +49,7 @@
 
     HIP_ASSERT(hcstore != NULL);
 
-    HIP_IFEL(!(msg = HIP_MALLOC(HIP_MAX_PACKET, 0)), -1,
+    HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
              "failed to allocate memory\n");
 
     hip_msg_init(msg);
@@ -162,7 +163,7 @@
 
     HIP_ASSERT(activate >= 0);
 
-    HIP_IFEL(!(msg = HIP_MALLOC(HIP_MAX_PACKET, 0)), -1,
+    HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
              "failed to allocate memory\n");
 
     hip_msg_init(msg);
@@ -323,7 +324,7 @@
     HIP_IFEL((hash_length = 
esp_prot_get_hash_length(entry->esp_prot_transform)) <= 0,
              -1, "error or tried to resolve UNUSED transform\n");
 
-    HIP_IFEL(!(msg = HIP_MALLOC(HIP_MAX_PACKET, 0)), -1,
+    HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
              "failed to allocate memory\n");
 
     hip_msg_init(msg);
@@ -488,7 +489,7 @@
     HIP_IFEL((hash_length = 
esp_prot_get_hash_length(entry->esp_prot_transform)) <= 0,
              -1, "error or tried to resolve UNUSED transform\n");
 
-    HIP_IFEL(!(msg = HIP_MALLOC(HIP_MAX_PACKET, 0)), -1,
+    HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
              "failed to allocate memory\n");
 
     hip_msg_init(msg);

=== modified file 'firewall/firewall.c'
--- firewall/firewall.c 2010-04-13 10:57:54 +0000
+++ firewall/firewall.c 2010-04-15 20:47:19 +0000
@@ -25,6 +25,7 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
 #include <limits.h> /* INT_MIN, INT_MAX */
 #include <netinet/in.h> /* in_addr, in6_addr */
 #include <linux/netfilter_ipv4.h> /* NF_IP_LOCAL_IN, etc */
@@ -2508,7 +2509,7 @@
         close(hip_fw_sock);
     }
     if (msg != NULL) {
-        HIP_FREE(msg);
+        free(msg);
     }
 
     firewall_exit();

=== modified file 'firewall/firewalldb.c'
--- firewall/firewalldb.c       2010-04-15 17:06:57 +0000
+++ firewall/firewalldb.c       2010-04-15 20:47:19 +0000
@@ -15,6 +15,7 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
 #include <netinet/ip_icmp.h>
 #include <netinet/icmp6.h>
 #include <netinet/udp.h>
@@ -100,7 +101,7 @@
 {
     firewall_hl_t *entry = NULL;
     int err              = 0;
-    HIP_IFEL(!(entry = HIP_MALLOC(sizeof(firewall_hl_t), 0)),
+    HIP_IFEL(!(entry = malloc(sizeof(firewall_hl_t))),
              -ENOMEM, "No memory available for firewall database entry\n");
     memset(entry, 0, sizeof(*entry));
 out_err:

=== modified file 'firewall/lsi.c'
--- firewall/lsi.c      2010-04-15 16:57:50 +0000
+++ firewall/lsi.c      2010-04-15 20:47:19 +0000
@@ -24,6 +24,7 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
 #include <netinet/ip6.h>
 #include <netinet/tcp.h>
 #include <netinet/udp.h>
@@ -138,7 +139,7 @@
 
 out_err:
     if (msg) {
-        HIP_FREE(msg);
+        free(msg);
     }
     return err;
 }
@@ -223,7 +224,7 @@
 
 out_err:
     if (msg) {
-        HIP_FREE(msg);
+        free(msg);
     }
     return res;
 }
@@ -621,7 +622,7 @@
     }
 
     if (msg) {
-        HIP_FREE(msg);
+        free(msg);
     }
     return err;
 }

=== modified file 'firewall/proxy.c'
--- firewall/proxy.c    2010-04-15 17:06:57 +0000
+++ firewall/proxy.c    2010-04-15 20:47:19 +0000
@@ -10,6 +10,7 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
 #include <netinet/icmp6.h>
 
 #include "firewall/proxy.h"
@@ -39,7 +40,7 @@
     struct hip_common *msg = NULL;
     int err                = 0;
     HIP_DEBUG("Sending hipproxy msg to hipd.\n");
-    HIP_IFEL(!(msg = HIP_MALLOC(HIP_MAX_PACKET, 0)), -1, "alloc\n");
+    HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1, "alloc\n");
     hip_msg_init(msg);
     HIP_IFEL(hip_build_user_hdr(msg,
                                 HIP_MSG_HIPPROXY_STATUS_REQUEST, 0),
@@ -676,7 +677,7 @@
         if (protocol == IPPROTO_TCP) {
             hip_raw_sock = hip_proxy_raw_sock_tcp_v4;
             sa_size      = sizeof(struct sockaddr_in);
-            msg          = HIP_MALLOC((len - sizeof(struct ip6_hdr) + 
sizeof(struct ip)), 0);
+            msg          = malloc((len - sizeof(struct ip6_hdr) + 
sizeof(struct ip)));
             memset(msg, 0, (len - sizeof(struct ip6_hdr) + sizeof(struct ip)));
 
             HIP_DEBUG_INADDR("ipv4 src address  inbound: ", &src4->sin_addr);
@@ -691,7 +692,7 @@
         if (protocol == IPPROTO_UDP) {
             hip_raw_sock = hip_proxy_raw_sock_udp_v4;
             sa_size      = sizeof(struct sockaddr_in);
-            msg          = HIP_MALLOC((len - sizeof(struct ip6_hdr) + 
sizeof(struct ip)), 0);
+            msg          = malloc((len - sizeof(struct ip6_hdr) + 
sizeof(struct ip)));
             memset(msg, 0, (len - sizeof(struct ip6_hdr) + sizeof(struct ip)));
 
             HIP_DEBUG_INADDR("ipv4 src address  inbound: ", &src4->sin_addr);
@@ -706,7 +707,7 @@
         if (protocol == IPPROTO_ICMP) {
             hip_raw_sock = hip_proxy_raw_sock_icmp_v4;
             sa_size      = sizeof(struct sockaddr_in);
-            msg          = HIP_MALLOC((len - sizeof(struct ip6_hdr) + 
sizeof(struct ip)), 0);
+            msg          = malloc((len - sizeof(struct ip6_hdr) + 
sizeof(struct ip)));
             memset(msg, 0, (len - sizeof(struct ip6_hdr) + sizeof(struct ip)));
 
             HIP_DEBUG_INADDR("ipv4 src address  inbound: ", &src4->sin_addr);
@@ -723,7 +724,7 @@
             HIP_DEBUG("Using IPv6 raw socket (TCP)\n");
             hip_raw_sock = hip_proxy_raw_sock_tcp_v6;
             sa_size      = sizeof(struct sockaddr_in6);
-            msg          = HIP_MALLOC(len, 0);
+            msg          = malloc(len);
             //memset(msg, 0, len);
             tcp->check   =  htons(0);
             tcp->check   = ipv6_checksum(IPPROTO_TCP, &(src6->sin6_addr), 
&(dst6->sin6_addr), tcp, (len - sizeof(struct ip6_hdr)));           //checksum 
is ok for ipv6
@@ -734,7 +735,7 @@
             HIP_DEBUG("Using IPv6 raw socket (UDP)\n");
             hip_raw_sock = hip_proxy_raw_sock_udp_v6;
             sa_size      = sizeof(struct sockaddr_in6);
-            msg          = HIP_MALLOC(len, 0);
+            msg          = malloc(len);
             //memset(msg, 0, len);
             udp->check   =  htons(0);
             udp->check   = ipv6_checksum(IPPROTO_UDP, &(src6->sin6_addr), 
&(dst6->sin6_addr), udp, (len - sizeof(struct ip6_hdr)));           //checksum 
is ok for ipv6
@@ -745,7 +746,7 @@
             HIP_DEBUG("Using IPv6 raw socket (ICMPV6)\n");
             hip_raw_sock        = hip_proxy_raw_sock_icmp_v6;
             sa_size             = sizeof(struct sockaddr_in6);
-            msg                 = HIP_MALLOC(len, 0);
+            msg                 = malloc(len);
             //memset(msg, 0, len);
             icmpv6->icmp6_cksum =  htons(0);
             icmpv6->icmp6_cksum = ipv6_checksum(IPPROTO_ICMPV6, 
&(src6->sin6_addr), &(dst6->sin6_addr), icmpv6, (len - sizeof(struct 
ip6_hdr)));             //checksum is ok for ipv6
@@ -976,7 +977,7 @@
     HIP_DEBUG_IN6ADDR("dst6", &dst6.sin6_addr);
 
     sa_size = sizeof(struct sockaddr_in6);
-    msg = HIP_MALLOC((len + sizeof(struct ip6_hdr) - ip->ip_hl), 0);
+    msg = malloc((len + sizeof(struct ip6_hdr) - ip->ip_hl));
     memset(msg, 0, (len + sizeof(struct ip6_hdr) - ip->ip_hl));
 
     ip6 = (struct ip6_hdr *) msg;
@@ -1130,7 +1131,7 @@
                 err = 0;
             } else {
                 packet_length = m->data_len - hdr_size;
-                msg           = HIP_MALLOC(packet_length, 0);
+                msg           = malloc(packet_length);
                 memcpy(msg, (m->payload) + hdr_size,
                        packet_length);
 

=== modified file 'firewall/user_ipsec_fw_msg.c'
--- firewall/user_ipsec_fw_msg.c        2010-04-13 16:51:53 +0000
+++ firewall/user_ipsec_fw_msg.c        2010-04-15 20:47:19 +0000
@@ -10,6 +10,8 @@
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
  */
 
+#include <stdlib.h>
+
 #include "esp_prot_fw_msg.h"
 #include "firewall.h"
 #include "user_ipsec_fw_msg.h"
@@ -29,7 +31,7 @@
     int err                = 0;
     struct hip_common *msg = NULL;
 
-    HIP_IFEL(!(msg = HIP_MALLOC(HIP_MAX_PACKET, 0)), -1,
+    HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
              "alloc memory for adding sa entry\n");
 
     hip_msg_init(msg);

=== modified file 'hipd/blind.c'
--- hipd/blind.c        2010-04-13 11:33:54 +0000
+++ hipd/blind.c        2010-04-15 20:47:19 +0000
@@ -9,6 +9,8 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
+
 #include "blind.h"
 #include "lib/core/hit.h"
 #include "lib/core/hostid.h"
@@ -34,10 +36,10 @@
     struct in6_addr *blind_hit = NULL;
 
     // generate key = nonce|hit_our
-    HIP_IFEL((key = HIP_MALLOC(sizeof(uint16_t) + sizeof(struct in6_addr), 0)) 
== NULL,
+    HIP_IFEL((key = malloc(sizeof(uint16_t) + sizeof(struct in6_addr))) == 
NULL,
              -1, "Couldn't allocate memory\n");
 
-    HIP_IFEL((blind_hit = HIP_MALLOC(sizeof(struct in6_addr), 0)) == NULL,
+    HIP_IFEL((blind_hit = malloc(sizeof(struct in6_addr))) == NULL,
              -1, "Couldn't allocate memory\n");
 
     HIP_READ_LOCK_DB(hip_local_hostid_db);
@@ -67,10 +69,10 @@
 
 out_err:
     if (key) {
-        HIP_FREE(key);
+        free(key);
     }
     if (blind_hit) {
-        HIP_FREE(blind_hit);
+        free(blind_hit);
     }
     return err;
 }
@@ -296,13 +298,13 @@
     get_random_bytes(&entry->blind_nonce_i, sizeof(uint16_t));
 
     // generate key = nonce|hit_our
-    HIP_IFEL((key_our = HIP_MALLOC(sizeof(uint16_t) + sizeof(struct in6_addr), 
0)) == NULL,
+    HIP_IFEL((key_our = malloc(sizeof(uint16_t) + sizeof(struct in6_addr))) == 
NULL,
              -1, "Couldn't allocate memory\n");
     memcpy(key_our, &entry->hit_our, sizeof(struct in6_addr));
     memcpy(key_our + sizeof(struct in6_addr), &entry->blind_nonce_i, 
sizeof(uint16_t));
 
     // generate key = nonce|hit_peer
-    HIP_IFEL((key_peer = HIP_MALLOC(sizeof(uint16_t) + sizeof(struct 
in6_addr), 0)) == NULL,
+    HIP_IFEL((key_peer = malloc(sizeof(uint16_t) + sizeof(struct in6_addr))) 
== NULL,
              -1, "Couldn't allocate memory\n");
     memcpy(key_peer, &entry->hit_peer, sizeof(struct in6_addr));
     memcpy(key_peer + sizeof(struct in6_addr), &entry->blind_nonce_i, 
sizeof(uint16_t));
@@ -336,7 +338,7 @@
 
     HIP_DEBUG("\n");
 
-    test_hit = HIP_MALLOC(sizeof(struct in6_addr), 0);
+    test_hit = malloc(sizeof(struct in6_addr));
     if (test_hit == NULL) {
         HIP_ERROR("Couldn't allocate memory\n");
         ret = -1;
@@ -344,7 +346,7 @@
     }
 
     // generate key = nonce|hit_our
-    key = HIP_MALLOC(sizeof(uint16_t) + sizeof(struct in6_addr), 0);
+    key = malloc(sizeof(uint16_t) + sizeof(struct in6_addr));
     if (key == NULL) {
         HIP_ERROR("Couldn't allocate memory\n");
         ret = -1;
@@ -366,7 +368,7 @@
 
 out_err:
     if (test_hit) {
-        HIP_FREE(test_hit);
+        free(test_hit);
     }
     return ret == 0;
 }
@@ -519,8 +521,7 @@
     HIP_IFEL(!(enc = hip_get_param(r2, HIP_PARAM_ENCRYPTED)),
              -ENOENT, "Could not find enc parameter\n");
 
-    HIP_IFEL(!(tmp_enc = HIP_MALLOC(hip_get_param_total_len(enc),
-                                    GFP_KERNEL)), -ENOMEM,
+    HIP_IFEL(!(tmp_enc = malloc(hip_get_param_total_len(enc))), -ENOMEM,
              "No memory for temporary host_id\n");
     memcpy(tmp_enc, enc, hip_get_param_total_len(enc));
 
@@ -564,7 +565,7 @@
     HIP_IFEL(hip_get_param_type(host_id_in_enc) != HIP_PARAM_HOST_ID, -EINVAL,
              "The decrypted parameter is not a host id\n");
 
-    HIP_IFEL((plain_peer_hit = HIP_MALLOC(sizeof(struct in6_addr), 0)) == NULL,
+    HIP_IFEL((plain_peer_hit = malloc(sizeof(struct in6_addr))) == NULL,
              -1, "Couldn't allocate memory\n");
     HIP_IFEL(hip_host_id_to_hit(host_id_in_enc, plain_peer_hit, 
HIP_HIT_TYPE_HASH100),
              -1, "hip_host_id_to_hit faile\n");
@@ -580,10 +581,10 @@
 
 out_err:
     if (tmp_enc) {
-        HIP_FREE(tmp_enc);
+        free(tmp_enc);
     }
     if (plain_peer_hit) {
-        HIP_FREE(plain_peer_hit);
+        free(plain_peer_hit);
     }
     return err;
 }
@@ -631,7 +632,7 @@
     /* Allocate memory for writing the first Diffie-Hellman shared secret */
     HIP_IFEL((dh_size1 = hip_get_dh_size(HIP_FIRST_DH_GROUP_ID)) == 0,
              -1, "Could not get dh_size1\n");
-    HIP_IFEL(!(dh_data1 = HIP_MALLOC(dh_size1, GFP_ATOMIC)),
+    HIP_IFEL(!(dh_data1 = malloc(dh_size1)),
              -1, "Failed to alloc memory for dh_data1\n");
     memset(dh_data1, 0, dh_size1);
 
@@ -640,7 +641,7 @@
     /* Allocate memory for writing the second Diffie-Hellman shared secret */
     HIP_IFEL((dh_size2 = hip_get_dh_size(HIP_SECOND_DH_GROUP_ID)) == 0,
              -1, "Could not get dh_size2\n");
-    HIP_IFEL(!(dh_data2 = HIP_MALLOC(dh_size2, GFP_ATOMIC)),
+    HIP_IFEL(!(dh_data2 = malloc(dh_size2)),
              -1, "Failed to alloc memory for dh_data2\n");
     memset(dh_data2, 0, dh_size2);
 
@@ -730,25 +731,25 @@
     /************** Packet ready ***************/
 
     if (dh_data1) {
-        HIP_FREE(dh_data1);
+        free(dh_data1);
     }
     if (dh_data2) {
-        HIP_FREE(dh_data2);
+        free(dh_data2);
     }
 
     return msg;
 
 out_err:
     //if (host_id_pub)
-    //    HIP_FREE(host_id_pub);
+    //    free(host_id_pub);
     if (msg) {
-        HIP_FREE(msg);
+        free(msg);
     }
     if (dh_data1) {
-        HIP_FREE(dh_data1);
+        free(dh_data1);
     }
     if (dh_data2) {
-        HIP_FREE(dh_data2);
+        free(dh_data2);
     }
 
     return NULL;

=== modified file 'hipd/bos.c'
--- hipd/bos.c  2010-04-13 11:10:38 +0000
+++ hipd/bos.c  2010-04-15 20:47:19 +0000
@@ -16,6 +16,8 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
+
 #include "bos.h"
 #include "lib/core/hostid.h"
 #include "lib/core/hip_udp.h"
@@ -198,10 +200,10 @@
 
 out_err:
     if (host_id_pub) {
-        HIP_FREE(host_id_pub);
+        free(host_id_pub);
     }
     if (bos) {
-        HIP_FREE(bos);
+        free(bos);
     }
     return err;
 }

=== modified file 'hipd/close.c'
--- hipd/close.c        2010-04-15 16:57:50 +0000
+++ hipd/close.c        2010-04-15 20:47:19 +0000
@@ -10,6 +10,8 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
+
 #include "config.h"
 #include "close.h"
 #include "lib/core/hip_udp.h"
@@ -111,7 +113,7 @@
 
 out_err:
     if (close) {
-        HIP_FREE(close);
+        free(close);
     }
 
     return err;
@@ -181,10 +183,10 @@
 
 out_err:
     if (msg_to_firewall) {
-        HIP_FREE(msg_to_firewall);
+        free(msg_to_firewall);
     }
     if (opaque) {
-        HIP_FREE(opaque);
+        free(opaque);
     }
     return err;
 }
@@ -280,7 +282,7 @@
 out_err:
 
     if (close_ack) {
-        HIP_FREE(close_ack);
+        free(close_ack);
     }
 
     return err;

=== modified file 'hipd/cookie.c'
--- hipd/cookie.c       2010-04-15 17:06:57 +0000
+++ hipd/cookie.c       2010-04-15 20:47:19 +0000
@@ -11,6 +11,8 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
+
 #include "config.h"
 #include "blind.h"
 #include "cookie.h"
@@ -238,7 +240,7 @@
 
 out_err:
     if (!err && r1) {
-        HIP_FREE(r1);
+        free(r1);
     }
 
     HIP_READ_UNLOCK_DB(HIP_DB_LOCAL_HID);
@@ -254,7 +256,7 @@
 {
     struct hip_r1entry *err;
 
-    HIP_IFE(!(err = HIP_MALLOC(sizeof(struct hip_r1entry) * HIP_R1TABLESIZE, 
0)),
+    HIP_IFE(!(err = malloc(sizeof(struct hip_r1entry) * HIP_R1TABLESIZE)),
             NULL);
     memset(err, 0, sizeof(struct hip_r1entry) * HIP_R1TABLESIZE);
 
@@ -316,10 +318,10 @@
     if (hip_r1table) {
         for (i = 0; i < HIP_R1TABLESIZE; i++) {
             if (hip_r1table[i].r1) {
-                HIP_FREE(hip_r1table[i].r1);
+                free(hip_r1table[i].r1);
             }
         }
-        HIP_FREE(hip_r1table);
+        free(hip_r1table);
         hip_r1table = NULL;
     }
 }

=== modified file 'hipd/dht.c'
--- hipd/dht.c  2010-04-09 16:24:44 +0000
+++ hipd/dht.c  2010-04-15 20:47:19 +0000
@@ -10,6 +10,8 @@
  * @author: Samu Varjonen <samu.varjonen@xxxxxxx>
  */
 
+#include <stdlib.h>
+
 #include "dht.h"
 #include "hipd.h"
 #include "lib/core/hostid.h"
@@ -249,7 +251,7 @@
     err = 0;
 out_err:
     if (hdrr_msg) {
-        HIP_FREE(hdrr_msg);
+        free(hdrr_msg);
     }
     return err;
 }

=== modified file 'hipd/hadb.c'
--- hipd/hadb.c 2010-04-15 17:06:57 +0000
+++ hipd/hadb.c 2010-04-15 20:47:19 +0000
@@ -37,6 +37,7 @@
  */
 
 #include <limits.h>
+#include <stdlib.h>
 
 #include "config.h"
 #include "hadb.h"
@@ -824,7 +825,7 @@
 /**
  * Allocate and initialize a new HA structure.
  *
- * @param  gfpmask a mask passed directly to HIP_MALLOC().
+ * @param  gfpmask a mask passed directly to malloc().
  * @return NULL if memory allocation failed, otherwise the HA.
  */
 hip_ha_t *hip_hadb_create_state(int gfpmask)
@@ -961,9 +962,9 @@
             /*Adding the peer address to the entry->peer_addr_list_to_be_added
              *                          * So that later aftre base exchange it 
can be transfered to
              *                                                   * SPI OUT's 
peer address list*/
-            a_item = HIP_MALLOC(sizeof(struct hip_peer_addr_list_item), 0);
+            a_item = malloc(sizeof(struct hip_peer_addr_list_item));
             if (!a_item) {
-                HIP_ERROR("item HIP_MALLOC failed\n");
+                HIP_ERROR("item malloc failed\n");
                 err = -ENOMEM;
                 goto out_err;
             }
@@ -982,9 +983,9 @@
         goto out_err;
     }
 
-    a_item = HIP_MALLOC(sizeof(struct hip_peer_addr_list_item), GFP_KERNEL);
+    a_item = malloc(sizeof(struct hip_peer_addr_list_item));
     if (!a_item) {
-        HIP_ERROR("item HIP_MALLOC failed\n");
+        HIP_ERROR("item malloc failed\n");
         err = -ENOMEM;
         goto out_err;
     }
@@ -1091,16 +1092,16 @@
                             ctx->current_keymat_K);
 
     if (entry->dh_shared_key) {
-        HIP_DEBUG("HIP_FREEing old dh_shared_key\n");
-        HIP_FREE(entry->dh_shared_key);
+        HIP_DEBUG("freeing old dh_shared_key\n");
+        free(entry->dh_shared_key);
         entry->dh_shared_key = NULL;
     }
 
     entry->dh_shared_key_len = 0;
-    /** @todo reuse pointer, no HIP_MALLOC */
-    entry->dh_shared_key     = HIP_MALLOC(ctx->dh_shared_key_len, GFP_ATOMIC);
+    /** @todo reuse pointer, no malloc */
+    entry->dh_shared_key     = malloc(ctx->dh_shared_key_len);
     if (!entry->dh_shared_key) {
-        HIP_ERROR("entry dh_shared HIP_MALLOC failed\n");
+        HIP_ERROR("entry dh_shared malloc failed\n");
         err = -ENOMEM;
         goto out_err;
     }
@@ -1113,7 +1114,7 @@
 
 out_err:
     if (entry->dh_shared_key) {
-        HIP_FREE(entry->dh_shared_key);
+        free(entry->dh_shared_key);
         entry->dh_shared_key = NULL;
     }
 
@@ -1147,7 +1148,7 @@
              ipv6_addr_cmp(&hit, &entry->hit_peer),
              -1, "Unable to verify sender's HOST_ID\n");
 
-    HIP_IFEL(!(entry->peer_pub = HIP_MALLOC(len, GFP_KERNEL)),
+    HIP_IFEL(!(entry->peer_pub = malloc(len)),
              -ENOMEM, "Out of memory\n");
 
     memcpy(entry->peer_pub, peer, len);
@@ -1220,7 +1221,7 @@
 out_err:
 
     if (err && entry->our_pub) {
-        HIP_FREE(entry->our_pub);
+        free(entry->our_pub);
         entry->our_pub = NULL;
     }
 
@@ -1603,7 +1604,7 @@
     list_for_each_safe(item, tmp, ha->addresses_to_send_echo_request, i) {
         address = (struct in6_addr *) list_entry(item);
         list_del(address, ha->addresses_to_send_echo_request);
-        HIP_FREE(address);
+        free(address);
     }
 }
 
@@ -1627,10 +1628,10 @@
     /* Delete SAs */
 
     if (ha->dh_shared_key) {
-        HIP_FREE(ha->dh_shared_key);
+        free(ha->dh_shared_key);
     }
     if (ha->hip_msg_retrans.buf) {
-        HIP_FREE(ha->hip_msg_retrans.buf);
+        free(ha->hip_msg_retrans.buf);
     }
     if (ha->peer_pub) {
         if (hip_get_host_id_algo(ha->peer_pub) == HIP_HI_RSA &&
@@ -1639,16 +1640,16 @@
         } else if (ha->peer_pub_key) {
             DSA_free(ha->peer_pub_key);
         }
-        HIP_FREE(ha->peer_pub);
+        free(ha->peer_pub);
     }
     if (ha->our_priv) {
-        HIP_FREE(ha->our_priv);
+        free(ha->our_priv);
     }
     if (ha->our_pub) {
-        HIP_FREE(ha->our_pub);
+        free(ha->our_pub);
     }
     if (ha->rendezvous_addr) {
-        HIP_FREE(ha->rendezvous_addr);
+        free(ha->rendezvous_addr);
     }
 
     if (ha->addresses_to_send_echo_request) {
@@ -1681,7 +1682,7 @@
     }
 
     list_del(ha, hadb_hit);
-    HIP_FREE(ha);
+    free(ha);
 }
 
 /**

=== modified file 'hipd/hadb_legacy.c'
--- hipd/hadb_legacy.c  2010-04-13 11:10:38 +0000
+++ hipd/hadb_legacy.c  2010-04-15 20:47:19 +0000
@@ -11,6 +11,8 @@
  * @author Miika Komu <miika@xxxxxx>
  */
 
+#include <stdlib.h>
+
 #include "hadb_legacy.h"
 
 /**
@@ -82,7 +84,7 @@
         if (!ipv6_addr_cmp(&peer_addr_list_item->address, addr)) {
             _HIP_DEBUG("deleting address\n");
             list_del(item, ha->peer_addresses_old);
-            HIP_FREE(item);
+            free(item);
             /* if address is on more than one spi list then do not goto out */
             goto out;
         }

=== modified file 'hipd/hidb.c'
--- hipd/hidb.c 2010-04-15 17:06:57 +0000
+++ hipd/hidb.c 2010-04-15 20:47:19 +0000
@@ -14,6 +14,8 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
+
 #include "config.h"
 #include "hidb.h"
 #include "lib/core/hostid.h"
@@ -133,9 +135,9 @@
         DSA_free(id->private_key);
     }
 
-    HIP_FREE(id->host_id);
+    free(id->host_id);
     list_del(id, db);
-    HIP_FREE(id);
+    free(id);
     id  = NULL;
 
     err = 0;
@@ -299,7 +301,7 @@
 
     HIP_ASSERT(&lhi->hit != NULL);
     _HIP_DEBUG("host id algo:%d \n", hip_get_host_id_algo(host_id));
-    HIP_IFEL(!(id_entry = HIP_MALLOC(sizeof(struct hip_host_id_entry), 0)),
+    HIP_IFEL(!(id_entry = malloc(sizeof(struct hip_host_id_entry))),
              -ENOMEM, "No memory available for host id\n");
     memset(id_entry, 0, sizeof(struct hip_host_id_entry));
 
@@ -361,9 +363,9 @@
                     DSA_free(id_entry->private_key);
                 }
             }
-            HIP_FREE(id_entry->host_id);
+            free(id_entry->host_id);
         }
-        HIP_FREE(id_entry);
+        free(id_entry);
     }
 
     HIP_WRITE_UNLOCK_DB(db);
@@ -782,7 +784,7 @@
     host_id_len = hip_get_param_total_len(entry->host_id);
     HIP_IFE(host_id_len > HIP_MAX_HOST_ID_LEN, -1);
 
-    *host_id    = HIP_MALLOC(host_id_len, GFP_ATOMIC);
+    *host_id    = malloc(host_id_len);
     HIP_IFE(!*host_id, -ENOMEM);
     memcpy(*host_id, entry->host_id, host_id_len);
 

=== modified file 'hipd/hiprelay.c'
--- hipd/hiprelay.c     2010-04-15 16:57:50 +0000
+++ hipd/hiprelay.c     2010-04-15 20:47:19 +0000
@@ -75,6 +75,8 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
+
 #include "config.h"
 #include "hiprelay.h"
 #include "output.h"
@@ -1218,7 +1220,7 @@
 
 out_err:
     if (r_to_be_relayed != NULL) {
-        HIP_FREE(r_to_be_relayed);
+        free(r_to_be_relayed);
     }
     return err;
 }

=== modified file 'hipd/init.c'
--- hipd/init.c 2010-04-13 11:20:27 +0000
+++ hipd/init.c 2010-04-15 20:47:19 +0000
@@ -10,6 +10,7 @@
 #define _BSD_SOURCE
 
 #include <limits.h>
+#include <stdlib.h>
 #include <sys/prctl.h>
 #include <sys/types.h>
 #include <netinet/icmp6.h>
@@ -629,7 +630,7 @@
 out_err:
 
     if (user_msg) {
-        HIP_FREE(user_msg);
+        free(user_msg);
     }
 
     return err;
@@ -780,10 +781,10 @@
     // hip_send_close(NULL, FLUSH_HA_INFO_DB);
 
     if (hipd_msg) {
-        HIP_FREE(hipd_msg);
+        free(hipd_msg);
     }
     if (hipd_msg_v4) {
-        HIP_FREE(hipd_msg_v4);
+        free(hipd_msg_v4);
     }
 
     hip_delete_all_sp();    //empty

=== modified file 'hipd/input.c'
--- hipd/input.c        2010-04-15 16:57:50 +0000
+++ hipd/input.c        2010-04-15 20:47:19 +0000
@@ -16,6 +16,8 @@
  */
 #define _BSD_SOURCE
 
+#include <stdlib.h>
+
 #include "config.h"
 #include "blind.h"
 #include "input.h"
@@ -207,7 +209,7 @@
 
 out_err:
     if (msg_copy) {
-        HIP_FREE(msg_copy);
+        free(msg_copy);
     }
 
     return err;
@@ -304,13 +306,13 @@
     HIP_DEBUG("Keying material:\n\tminimum length = %u\n\t" \
               "keying material length = %u.\n", keymat_len_min, keymat_len);
 
-    HIP_IFEL(!(keymat = HIP_MALLOC(keymat_len, 0)), -ENOMEM,
+    HIP_IFEL(!(keymat = malloc(keymat_len)), -ENOMEM,
              "Error on allocating memory for keying material.\n");
 
     /* 1024 should be enough for shared secret. The length of the shared
      * secret actually depends on the DH Group. */
     /** @todo 1024 -> hip_get_dh_size ? */
-    HIP_IFEL(!(dh_shared_key = HIP_MALLOC(dh_shared_len, GFP_0)),
+    HIP_IFEL(!(dh_shared_key = malloc(dh_shared_len)),
              -ENOMEM,
              "Error on allocating memory for Diffie-Hellman shared key.\n");
 
@@ -372,7 +374,7 @@
             /* Responder produces keying material for handling I2:
              * uses own plain hit and blinded initiator hit */
             else if (type == HIP_I2) {
-                HIP_IFEL((plain_local_hit = HIP_MALLOC(sizeof(struct 
in6_addr), 0)) == NULL,
+                HIP_IFEL((plain_local_hit = malloc(sizeof(struct in6_addr))) 
== NULL,
                          -1, "Couldn't allocate memory\n");
                 HIP_IFEL(hip_blind_get_nonce(msg, &nonce), -1, 
"hip_blind_get_nonce failed\n");
                 HIP_IFEL(hip_plain_fingerprint(&nonce, &msg->hitr, 
plain_local_hit),
@@ -473,16 +475,16 @@
     ctx->dh_shared_key     = dh_shared_key;
     ctx->dh_shared_key_len = dh_shared_len;
 
-    /* on success HIP_FREE for dh_shared_key is called by caller */
+    /* on success free for dh_shared_key is called by caller */
 out_err:
     if (err && dh_shared_key) {
-        HIP_FREE(dh_shared_key);
+        free(dh_shared_key);
     }
     if (keymat) {
-        HIP_FREE(keymat);
+        free(keymat);
     }
     if (plain_local_hit) {
-        HIP_FREE(plain_local_hit);
+        free(plain_local_hit);
     }
     return err;
 }
@@ -1277,7 +1279,7 @@
 
 out_err:
     if (i2) {
-        HIP_FREE(i2);
+        free(i2);
     }
 
     return err;
@@ -1403,7 +1405,7 @@
         HIP_DEBUG("Not a retransmission\n");
     }
 
-    HIP_IFEL(!(ctx = HIP_MALLOC(sizeof(struct hip_context), 0)),
+    HIP_IFEL(!(ctx = malloc(sizeof(struct hip_context))),
              -ENOMEM, "Could not allocate memory for context\n");
     memset(ctx, 0, sizeof(struct hip_context));
     ctx->input = r1;
@@ -1545,10 +1547,10 @@
 
 out_err:
     if (ctx->dh_shared_key) {
-        HIP_FREE(ctx->dh_shared_key);
+        free(ctx->dh_shared_key);
     }
     if (ctx) {
-        HIP_FREE(ctx);
+        free(ctx);
     }
 
     return err;
@@ -2673,7 +2675,7 @@
     }
 
     /* assume already locked entry */
-    HIP_IFE(!(ctx = HIP_MALLOC(sizeof(struct hip_context), 0)), -ENOMEM);
+    HIP_IFE(!(ctx = malloc(sizeof(struct hip_context))), -ENOMEM);
     memset(ctx, 0, sizeof(struct hip_context));
     ctx->input = r2;
 
@@ -2881,7 +2883,7 @@
     }
 
     if (ctx) {
-        HIP_FREE(ctx);
+        free(ctx);
     }
     return err;
 }

=== modified file 'hipd/keymat.c'
--- hipd/keymat.c       2010-04-15 17:06:57 +0000
+++ hipd/keymat.c       2010-04-15 20:47:19 +0000
@@ -10,6 +10,8 @@
  * @author Tobias Heer <heer#tobibox.de>
  */
 
+#include <stdlib.h>
+
 #include "keymat.h"
 #include "lib/core/hit.h"
 
@@ -43,7 +45,7 @@
         requiredmem = kij_len + 2 * sizeof(struct in6_addr) +
                       sizeof(uint8_t) + 2 * sizeof(uint64_t);
     }
-    buffer = HIP_MALLOC(requiredmem, 0);
+    buffer = malloc(requiredmem);
     if (!buffer) {
         HIP_ERROR("Out of memory\n");
         return buffer;
@@ -187,7 +189,7 @@
     _HIP_DEBUG("keymat index_nbr=%u\n", index_nbr);
     _HIP_HEXDUMP("GENERATED KEYMAT: ", dstbuf, dstbuflen);
     if (shabuffer) {
-        HIP_FREE(shabuffer);
+        free(shabuffer);
     }
 
     return;
@@ -327,14 +329,14 @@
     _HIP_DEBUG("need %d bytes more data\n", key_len - copied);
 
     tmp_data_len = kij_len + HIP_AH_SHA_LEN + 1;
-    tmp_data     = HIP_MALLOC(tmp_data_len, 0);
+    tmp_data     = malloc(tmp_data_len);
     if (!tmp_data) {
-        HIP_ERROR("HIP_MALLOC failed\n");
+        HIP_ERROR("malloc failed\n");
         err = -ENOMEM;
         goto out_err;
     }
 
-    memcpy(tmp_data, kij, kij_len);     /* fixed part of every Kn round */
+    memcpy(tmp_data);     /* fixed part of every Kn round */
 
     while (copied < key_len) {
         (*calc_index)++;
@@ -379,7 +381,7 @@
                *keymat_index, *calc_index);
 out_err:
     if (tmp_data) {
-        HIP_FREE(tmp_data);
+        free(tmp_data);
     }
     return err;
 }

=== modified file 'hipd/maintenance.c'
--- hipd/maintenance.c  2010-04-14 13:08:33 +0000
+++ hipd/maintenance.c  2010-04-15 20:47:19 +0000
@@ -18,6 +18,8 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
+
 #include "config.h"
 #include "maintenance.h"
 #include "update.h"
@@ -537,7 +539,7 @@
     /* Makes sure that the hits are sent always in the same order */
     r_is_our = hip_hidb_hit_is_our(hit_r);
 
-    HIP_IFEL(!(msg = HIP_MALLOC(HIP_MAX_PACKET, 0)), -1, "alloc\n");
+    HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1, "alloc\n");
     hip_msg_init(msg);
     HIP_IFEL(hip_build_user_hdr(msg, action, 0), -1,
              "Build hdr failed\n");

=== modified file 'hipd/netdev.c'
--- hipd/netdev.c       2010-04-15 16:57:50 +0000
+++ hipd/netdev.c       2010-04-15 20:47:19 +0000
@@ -21,6 +21,7 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
 #include <net/if.h>
 #include <netinet/in.h>
 #include <sys/ioctl.h>
@@ -507,7 +508,7 @@
             n = (struct netdev_address *) list_entry(item);
             HIP_DEBUG_HIT("address to be deleted\n", hip_cast_sa_addr((struct 
sockaddr *) &n->addr));
             list_del(n, addresses);
-            HIP_FREE(n);
+            free(n);
             address_count--;
         }
         if (address_count != 0) {

=== modified file 'hipd/oppdb.c'
--- hipd/oppdb.c        2010-04-15 16:57:50 +0000
+++ hipd/oppdb.c        2010-04-15 20:47:19 +0000
@@ -37,6 +37,8 @@
  * - Bing Zhou <bingzhou@xxxxxxxxx>
  */
 
+#include <stdlib.h>
+
 #include "config.h"
 #include "oppdb.h"
 #include "hadb.h"
@@ -173,7 +175,7 @@
     deleted = hip_ht_delete(oppdb, entry);
     HIP_UNLOCK_OPP(entry);
     free(deleted);
-    //HIP_FREE(entry);
+    //free(entry);
 }
 
 /**
@@ -273,7 +275,7 @@
     }
 out_err:
     if (message) {
-        HIP_FREE(message);
+        free(message);
     }
     return err;
 }

=== modified file 'hipd/output.c'
--- hipd/output.c       2010-04-15 16:57:50 +0000
+++ hipd/output.c       2010-04-15 20:47:19 +0000
@@ -15,6 +15,7 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
 #include <netinet/icmp6.h>
 
 #include "config.h"
@@ -214,7 +215,7 @@
     err = sendto(sockfd, &newHdr[0], newSize, 0, (struct sockaddr *) 
&sin_addr, sizeof(sin_addr));
 
     if (defaultHit) {
-        HIP_FREE(defaultHit);
+        free(defaultHit);
     }
 
     setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, (char *) &off, sizeof(off));
@@ -589,7 +590,7 @@
     /* Allocate memory for writing the first Diffie-Hellman shared secret */
     HIP_IFEL((dh_size1 = hip_get_dh_size(HIP_FIRST_DH_GROUP_ID)) == 0,
              -1, "Could not get dh_size1\n");
-    HIP_IFEL(!(dh_data1 = HIP_MALLOC(dh_size1, GFP_ATOMIC)),
+    HIP_IFEL(!(dh_data1 = malloc(dh_size1)),
              -1, "Failed to alloc memory for dh_data1\n");
     memset(dh_data1, 0, dh_size1);
 
@@ -598,7 +599,7 @@
     /* Allocate memory for writing the second Diffie-Hellman shared secret */
     HIP_IFEL((dh_size2 = hip_get_dh_size(HIP_SECOND_DH_GROUP_ID)) == 0,
              -1, "Could not get dh_size2\n");
-    HIP_IFEL(!(dh_data2 = HIP_MALLOC(dh_size2, GFP_ATOMIC)),
+    HIP_IFEL(!(dh_data2 = malloc(dh_size2)),
              -1, "Failed to alloc memory for dh_data2\n");
     memset(dh_data2, 0, dh_size2);
 
@@ -702,23 +703,23 @@
     /* Packet ready */
 
     if (dh_data1) {
-        HIP_FREE(dh_data1);
+        free(dh_data1);
     }
     if (dh_data2) {
-        HIP_FREE(dh_data2);
+        free(dh_data2);
     }
 
     return msg;
 
 out_err:
     if (msg) {
-        HIP_FREE(msg);
+        free(msg);
     }
     if (dh_data1) {
-        HIP_FREE(dh_data1);
+        free(dh_data1);
     }
     if (dh_data2) {
-        HIP_FREE(dh_data2);
+        free(dh_data2);
     }
 
     return NULL;
@@ -919,10 +920,10 @@
 
 out_err:
     if (r1pkt) {
-        HIP_FREE(r1pkt);
+        free(r1pkt);
     }
     if (local_plain_hit) {
-        HIP_FREE(local_plain_hit);
+        free(local_plain_hit);
     }
     return err;
 }

=== modified file 'hipd/update_legacy.c'
--- hipd/update_legacy.c        2010-04-09 16:24:44 +0000
+++ hipd/update_legacy.c        2010-04-15 20:47:19 +0000
@@ -9,6 +9,8 @@
  * @author Baris Boyvat
  */
 
+#include <stdlib.h>
+
 #include "update_legacy.h"
 
 /**
@@ -99,7 +101,7 @@
         err = err > 0 ? 0 : -1;
 
 out_err:
-        HIP_FREE(msg);
+        free(msg);
         if (err) {
             HIP_ERROR("Couldn't flush firewall chains\n");
         }

=== modified file 'hipd/user_ipsec_hipd_msg.c'
--- hipd/user_ipsec_hipd_msg.c  2010-04-09 16:24:44 +0000
+++ hipd/user_ipsec_hipd_msg.c  2010-04-15 20:47:19 +0000
@@ -10,6 +10,8 @@
  * @author Rene Hummen <rene.hummen@xxxxxxxxxxxxxx>
  */
 
+#include <stdlib.h>
+
 #include "user_ipsec_hipd_msg.h"
 #include "hipd.h"
 #include "init.h"
@@ -122,7 +124,7 @@
     struct hip_common *msg = NULL;
     int err                = 0;
 
-    HIP_IFEL(!(msg = HIP_MALLOC(HIP_MAX_PACKET, 0)), -1,
+    HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
              "alloc memory for adding sa entry\n");
 
     hip_msg_init(msg);
@@ -240,7 +242,7 @@
     struct hip_common *msg = NULL;
     int err                = 0;
 
-    HIP_IFEL(!(msg = HIP_MALLOC(HIP_MAX_PACKET, 0)), -1,
+    HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
              "alloc memory for adding sa entry\n");
 
     hip_msg_init(msg);
@@ -293,7 +295,7 @@
     struct hip_common *msg = NULL;
     int err                = 0;
 
-    HIP_IFEL(!(msg = HIP_MALLOC(HIP_MAX_PACKET, 0)), -1,
+    HIP_IFEL(!(msg = malloc(HIP_MAX_PACKET)), -1,
              "alloc memory for adding sa entry\n");
 
     hip_msg_init(msg);

=== modified file 'lib/core/builder.c'
--- lib/core/builder.c  2010-04-15 17:06:57 +0000
+++ lib/core/builder.c  2010-04-15 20:47:19 +0000
@@ -67,6 +67,8 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
+
 #include "config.h"
 #include "builder.h"
 #include "hipd/input.h"
@@ -200,7 +202,7 @@
 {
     struct hip_common *ptr;
 
-    ptr = HIP_MALLOC(HIP_MAX_PACKET, 0);
+    ptr = malloc(HIP_MAX_PACKET);
     if (ptr) {
         hip_msg_init(ptr);
     }
@@ -213,7 +215,7 @@
  */
 void hip_msg_free(struct hip_common *msg)
 {
-    HIP_FREE(msg);
+    free(msg);
 }
 
 /**
@@ -1986,7 +1988,7 @@
     err = hip_build_param(msg, &hmac2);
 out_err:
     if (msg_copy) {
-        HIP_FREE(msg_copy);
+        free(msg_copy);
     }
 
     return err;
@@ -2089,7 +2091,7 @@
     if (rem) {
         HIP_DEBUG("Adjusting param size to AES block size\n");
 
-        param_padded = HIP_MALLOC(param_len + rem, 0);
+        param_padded = malloc(param_len + rem);
         if (!param_padded) {
             err = -ENOMEM;
             goto out_err;
@@ -2114,7 +2116,7 @@
 out_err:
 
     if (param_padded) {
-        HIP_FREE(param_padded);
+        free(param_padded);
     }
 
     return err;
@@ -2784,7 +2786,7 @@
     }
 
     /* Allocating memory for the "value" packet */
-    HIP_IFEL(!(value = value_tmp = HIP_MALLOC((pubkey_len), 0)),
+    HIP_IFEL(!(value = value_tmp = malloc((pubkey_len))),
              -1, "Failed to alloc memory for value\n");
 
     hip_calc_generic_param_len((struct hip_tlv_common *) &diffie_hellman,
@@ -2818,7 +2820,7 @@
 out_err:
 
     if (value) {
-        HIP_FREE(value);
+        free(value);
     }
 
     return err;
@@ -4307,7 +4309,7 @@
     struct hip_host_id host_id_hdr;
     hip_build_param_host_id_hdr(&host_id_hdr, hostname, key_rr_len, algo);
 
-    *host_id = HIP_MALLOC(hip_get_param_total_len(&host_id_hdr), 0);
+    *host_id = malloc(hip_get_param_total_len(&host_id_hdr));
     if (!host_id) {
         err = -ENOMEM;
     }
@@ -4349,7 +4351,7 @@
 out_err:
     if (err && *host_id) {
         *host_id = NULL;
-        HIP_FREE(host_id);
+        free(host_id);
     }
 
     return err;
@@ -4451,13 +4453,13 @@
 out_err:
 
     if (key_rr) {
-        HIP_FREE(key_rr);
+        free(key_rr);
     }
     if (host_id) {
-        HIP_FREE(host_id);
+        free(host_id);
     }
     if (host_id_pub) {
-        HIP_FREE(host_id_pub);
+        free(host_id_pub);
     }
 
     return err;

=== modified file 'lib/core/builder.h'
--- lib/core/builder.h  2010-04-13 15:59:48 +0000
+++ lib/core/builder.h  2010-04-15 20:47:19 +0000
@@ -21,9 +21,6 @@
 #include "hipd/registration.h"
 #include "state.h"
 
-#define HIP_MALLOC(size, flags)  malloc(size)
-#define HIP_FREE(obj)            free(obj)
-
 /* Removed in 2.6.11 - why ? */
 extern struct hip_cert_spki_info hip_cert_spki_info;
 

=== modified file 'lib/core/filemanip.c'
--- lib/core/filemanip.c        2010-03-09 18:26:22 +0000
+++ lib/core/filemanip.c        2010-04-15 20:47:19 +0000
@@ -8,12 +8,12 @@
  * @author Miika Komu <miika@xxxxxx>
  */
 
-#include "filemanip.h"
-
+#include <stdlib.h>
 #include <unistd.h>
 
 #include "config.h"
 #include "crypto.h"
+#include "filemanip.h"
 
 /**
  * get rid of a lock file
@@ -192,7 +192,7 @@
 
 out_err:
     if (pubfilename) {
-        HIP_FREE(pubfilename);
+        free(pubfilename);
     }
 
     return;

=== modified file 'lib/core/hostid.c'
--- lib/core/hostid.c   2010-04-15 17:06:57 +0000
+++ lib/core/hostid.c   2010-04-15 20:47:19 +0000
@@ -87,7 +87,7 @@
     _HIP_HEXDUMP("key_rr", key_rr, key_rr_len);
 
     /* Hash Input :=  Context ID | Input */
-    khi_data   = HIP_MALLOC(khi_data_len, 0);
+    khi_data   = malloc(khi_data_len);
     khi_index  = 0;
     memcpy(khi_data + khi_index, khi_context_id, sizeof(khi_context_id));
     khi_index += sizeof(khi_context_id);
@@ -117,7 +117,7 @@
 
 out_err:
     if (khi_data) {
-        HIP_FREE(khi_data);
+        free(khi_data);
     }
 
     return err;
@@ -175,7 +175,7 @@
 
     /* Allocate enough space for host id; there will be 20 bytes extra
      * to avoid hassle with padding. */
-    host_id_pub = HIP_MALLOC(total_len, 0);
+    host_id_pub = malloc(total_len);
     HIP_IFE(!host_id_pub, -EFAULT);
     memset(host_id_pub, 0, total_len);
 
@@ -197,7 +197,7 @@
 out_err:
 
     if (host_id_pub) {
-        HIP_FREE(host_id_pub);
+        free(host_id_pub);
     }
 
     return err;
@@ -438,7 +438,7 @@
     int len                      = hip_get_param_total_len(peer_host_id);
     char *key                    = NULL;
 
-    HIP_IFEL(!(peer_pub = HIP_MALLOC(len, 0)),
+    HIP_IFEL(!(peer_pub = malloc(len)),
              -ENOMEM, "Out of memory\n");
 
     memcpy(peer_pub, peer_host_id, len);

=== modified file 'lib/tool/nlink.c'
--- lib/tool/nlink.c    2010-04-15 16:57:50 +0000
+++ lib/tool/nlink.c    2010-04-15 20:47:19 +0000
@@ -29,6 +29,7 @@
 
 #define _BSD_SOURCE
 
+#include <stdlib.h>
 #include <net/if.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
@@ -875,7 +876,7 @@
 out_err:
     for (i = 0; i < 16; i++) {
         if (idxmap[i]) {
-            HIP_FREE(idxmap[i]);
+            free(idxmap[i]);
         }
     }
 
@@ -1218,7 +1219,7 @@
     int err = 0;
 
     if (slash) {
-        HIP_IFEL(!(aux_slash = HIP_MALLOC(sizeof(slash), 0)), -1, "alloc\n");
+        HIP_IFEL(!(aux_slash = malloc(sizeof(slash))), -1, "alloc\n");
         strcpy(aux_slash, slash);
         *slash = 0;
     }
@@ -1233,7 +1234,7 @@
 
 out_err:
     if (aux_slash) {
-        HIP_FREE(aux_slash);
+        free(aux_slash);
     }
     return err;
 }
@@ -1314,7 +1315,7 @@
 
 out_err:
     if (res) {
-        HIP_FREE(res);
+        free(res);
     }
     return 0;
 }
@@ -1417,7 +1418,7 @@
             strcat(strcat(res, dev), label);
             err      = do_chflags(res, flags, mask);
             if (res) {
-                HIP_FREE(res);
+                free(res);
             }
         }
     }

=== modified file 'test/hashtest.c'
--- test/hashtest.c     2010-04-15 16:57:50 +0000
+++ test/hashtest.c     2010-04-15 20:47:19 +0000
@@ -123,7 +123,7 @@
 //      if (atomic_read(&item->refcnt) > 2)
 //          HIP_ERROR("socketdb: %p, in use while removing it from 
socketdb\n", item);
         //hip_socketdb_put_entry(item);
-        HIP_FREE((void *) list_entry(item));
+        free((void *) list_entry(item));
     }
 //}
 
@@ -209,7 +209,7 @@
     //HIP_LOCK_SOCKET(entry);
     hip_ht_delete(socketdb, entry);
     //HIP_UNLOCK_SOCKET(entry);
-    HIP_FREE(entry);
+    free(entry);
 }
 
 static int hip_socketdb_del_entry(int pid, int socket)

Other related posts:

  • » [hipl-commit] [trunk] Rev 4299: Eliminate HIP_FREE / HIP_MALLOC macros. - Diego Biurrun