Use rad_malloc() instead of malloc() + NULL test.
authorfcusack <fcusack>
Fri, 18 Jan 2002 02:35:30 +0000 (02:35 +0000)
committerfcusack <fcusack>
Fri, 18 Jan 2002 02:35:30 +0000 (02:35 +0000)
Fix prototype/function call mismatches.
Bug noted by Lance Uyehara <lance@verniernetworks.com>.

src/modules/rlm_eap/eap.h
src/modules/rlm_eap/mem.c

index 11b6290..a6dcec7 100644 (file)
@@ -2,6 +2,7 @@
 #define _EAP_H
 
 #if HAVE_NETINET_IN_H
+#include <sys/types.h>
 #include <netinet/in.h>
 #endif
 
index 115d09c..11673aa 100644 (file)
 #include "eap.h"
 
 /*
- *      Allocate a new EAP_PACKET
+ *      Allocate a new EAP_PACKET.  Guaranteed to succeed.
  */
-EAP_PACKET *eap_packet_alloc()
+EAP_PACKET *eap_packet_alloc(void)
 {
         EAP_PACKET   *rp;
 
-        if ((rp = malloc(sizeof(EAP_PACKET))) == NULL) {
-                radlog(L_ERR, "out of memory");
-                return NULL;
-        }
+        rp = rad_malloc(sizeof(EAP_PACKET));
         memset(rp, 0, sizeof(EAP_PACKET));
         return rp;
 }
@@ -61,23 +58,14 @@ void eap_packet_free(EAP_PACKET **eap_packet_ptr)
 /*
  *      Allocate a new EAP_PACKET
  */
-EAP_DS *eap_ds_alloc()
+EAP_DS *eap_ds_alloc(void)
 {
         EAP_DS *eap_ds;
-        
-        if ((eap_ds = malloc(sizeof(EAP_DS))) == NULL) {
-                radlog(L_ERR, "out of memory");
-                return NULL;
-        }
+
+       eap_ds = rad_malloc(sizeof(EAP_DS));
         memset(eap_ds, 0, sizeof(EAP_DS));
-       if ((eap_ds->response = eap_packet_alloc(sizeof(EAP_PACKET))) == NULL) {
-               eap_ds_free(&eap_ds);
-               return NULL;
-       }
-       if ((eap_ds->request = eap_packet_alloc(sizeof(EAP_PACKET))) == NULL) {
-               eap_ds_free(&eap_ds);
-               return NULL;
-       }
+       eap_ds->response = eap_packet_alloc();
+       eap_ds->request = eap_packet_alloc();
 
        return eap_ds;
 }