btrace: Fix memory leak in btrace_clear.
[deliverable/binutils-gdb.git] / gdb / common / queue.h
index fce43493955be3d70a183719d619e3b3bb17bfd5..6314ad5ca62c3b9aaeccc44392ba57867c2c1500 100644 (file)
@@ -1,6 +1,6 @@
 /* General queue data structure for GDB, the GNU debugger.
 
-   Copyright (C) 2012-2015 Free Software Foundation, Inc.
+   Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -125,8 +125,7 @@ QUEUE(TYPE)                                 \
 void                                                                   \
 queue_ ## TYPE ## _enque (QUEUE (TYPE) *q, TYPE v)                     \
 {                                                                      \
-  QUEUE_ELEM (TYPE) *p                                                 \
-    = xmalloc (sizeof (QUEUE_ELEM (TYPE)));                            \
+  QUEUE_ELEM (TYPE) *p = XNEW (QUEUE_ELEM (TYPE));                     \
                                                                        \
   gdb_assert (q != NULL);                                              \
   p->data = v;                                                         \
@@ -229,9 +228,8 @@ queue_ ## TYPE ## _iterate (QUEUE (TYPE) *q,                                \
 QUEUE (TYPE) *                                                         \
 queue_ ## TYPE ## _alloc (void (*free_func) (TYPE))                    \
 {                                                                      \
-  QUEUE (TYPE) *q;                                                     \
+  QUEUE (TYPE) *q = XNEW (QUEUE (TYPE));                               \
                                                                        \
-  q = (QUEUE (TYPE) *) xmalloc (sizeof (QUEUE (TYPE)));                \
   q->head = NULL;                                                      \
   q->tail = NULL;                                                      \
   q->free_func = free_func;                                            \
This page took 0.025133 seconds and 4 git commands to generate.