Skip to contentSkip to conversation

libxl: Use libxl__realloc in a couple of places in libxl_events.c

PATCH In review Ian Campbell 2 participants 3 messages Oct 16, 2012 – Oct 25, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: Use libxl__realloc in a couple of places in libxl_events.c

# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1350402378 -3600
# Node ID fd0989ae4407fe630b93e9dd8ec15eea07c7825b
# Parent 33487389f7f24f91ee4ff03bddfd8eb0b2c47ce1
libxl: Use libxl__realloc in a couple of places in libxl_events.c

This avoids us having to think about the error handling on failure.

tools/libxl/libxl_event.c +3 -2
diff -r 33487389f7f2 -r fd0989ae4407 tools/libxl/libxl_event.c
@@ -489,7 +489,8 @@ int libxl__ev_xswatch_register(libxl__gc
         int newarraysize = (CTX->watch_nslots + 1) << 2;
         int i;
         libxl__ev_watch_slot *newarray =
-            realloc(CTX->watch_slots, sizeof(*newarray) * newarraysize);
+            libxl__realloc(NOGC,
+                           CTX->watch_slots, sizeof(*newarray) * newarraysize);
         if (!newarray) goto out_nomem;
         for (i = CTX->watch_nslots; i < newarraysize; i++)
             LIBXL_SLIST_INSERT_HEAD(&CTX->watch_freeslots,
@@ -1343,7 +1344,7 @@ static int eventloop_iteration(libxl__eg
 
         struct pollfd *newarray =
             (nfds > INT_MAX / sizeof(struct pollfd) / 2) ? 0 :
-            realloc(poller->fd_polls, sizeof(*newarray) * nfds);
+            libxl__realloc(NOGC, poller->fd_polls, sizeof(*newarray) * nfds);
 
         if (!newarray) { rc = ERROR_NOMEM; goto out; }
Acked-by on v1 1/1
#1 lore raw

Ian Campbell writes ("[PATCH] libxl: Use libxl__realloc in a couple of places in libxl_events.c"):

Quoted 3 lines

libxl: Use libxl__realloc in a couple of places in libxl_events.c

This avoids us having to think about the error handling on failure.

As far as it goes,

But...

tools/libxl/libxl_event.c int libxl__ev_xswatch_register(libxl__gc · line 494

Quoted 13 lines

diff -r 33487389f7f2 -r fd0989ae4407 tools/libxl/libxl_event.c

tools/libxl/libxl_event.c +2 -1
@@ -489,7 +489,8 @@ int libxl__ev_xswatch_register(libxl__gc
         int newarraysize = (CTX->watch_nslots + 1) << 2;
         int i;
         libxl__ev_watch_slot *newarray =
-            realloc(CTX->watch_slots, sizeof(*newarray) * newarraysize);
+            libxl__realloc(NOGC,
+                           CTX->watch_slots, sizeof(*newarray) * newarraysize);
         if (!newarray) goto out_nomem;

So did you want to remove the error exits then too ?

Quoted 4 lines
tools/libxl/libxl_event.c +1 -1
-            realloc(poller->fd_polls, sizeof(*newarray) * nfds);
+            libxl__realloc(NOGC, poller->fd_polls, sizeof(*newarray) * nfds);
 
         if (!newarray) { rc = ERROR_NOMEM; goto out; }

And here.

Ian.

#2 lore raw

Ian Jackson writes ("Re: [Xen-devel] [PATCH] libxl: Use libxl__realloc in a couple of places in libxl_events.c"):

Quoted 8 lines

Ian Campbell writes ("[PATCH] libxl: Use libxl__realloc in a couple of places in libxl_events.c"):

Quoted 3 lines

libxl: Use libxl__realloc in a couple of places in libxl_events.c

This avoids us having to think about the error handling on failure.

As far as it goes,

Ian.