Hi all,

A minor diff below for pqueue.

* Don't cast return value of malloc
* Avoid testing pointers for NULL before free-ing
* Use calloc() instead of malloc() + memset()
Index: pqueue.c
===================================================================
RCS file: /cvs/src/lib/libssl/src/crypto/pqueue/pqueue.c,v
retrieving revision 1.4
diff -u -p -r1.4 pqueue.c
--- pqueue.c    27 Apr 2014 20:20:59 -0000      1.4
+++ pqueue.c    28 Apr 2014 23:11:57 -0000
@@ -69,8 +69,9 @@ typedef struct _pqueue {
 pitem *
 pitem_new(unsigned char *prio64be, void *data)
 {
-       pitem *item = (pitem *)malloc(sizeof(pitem));
+       pitem *item;
 
+       item = malloc(sizeof(pitem));
        if (item == NULL)
                return NULL;
 
@@ -85,30 +86,23 @@ pitem_new(unsigned char *prio64be, void 
 void
 pitem_free(pitem *item)
 {
-       if (item == NULL)
-               return;
-
        free(item);
 }
 
 pqueue_s *
 pqueue_new(void)
 {
-       pqueue_s *pq = (pqueue_s *)malloc(sizeof(pqueue_s));
+       pqueue_s *pq;
 
+       pq = calloc(1, sizeof(pqueue_s));
        if (pq == NULL)
                return NULL;
-
-       memset(pq, 0x00, sizeof(pqueue_s));
        return pq;
 }
 
 void
 pqueue_free(pqueue_s *pq)
 {
-       if (pq == NULL)
-               return;
-
        free(pq);
 }
 

Reply via email to