Thread (14 messages) flat view 14 messages, 3 authors, 2018-08-12

Re: [PATCH v3 2/8] Add delta-islands.{c,h}

From: Christian Couder <hidden>
Date: 2018-08-11 10:32:35
Subsystem: the rest · Maintainer: Linus Torvalds

On Sat, Aug 11, 2018 at 11:04 AM, SZEDER Gábor [off-list ref] wrote:
quoted
diff --git a/delta-islands.c b/delta-islands.c
new file mode 100644
index 0000000000..448ddcbbe4
--- /dev/null
+++ b/delta-islands.c
quoted
+static void deduplicate_islands(void)
+{
+     struct remote_island *island, *core = NULL, **list;
+     unsigned int island_count, dst, src, ref, i = 0;
+
+     island_count = kh_size(remote_islands);
+     list = xmalloc(island_count * sizeof(struct remote_island *));
Please use ALLOC_ARRAY here.
Ok, I have made the following changes in the branch I will send next.
diff --git a/delta-islands.c b/delta-islands.c
index 92137f2eca..22e4360810 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -322,8 +322,7 @@ static int island_config_callback(const char *k,
const char *v, void *cb)

                if (island_regexes_nr >= island_regexes_alloc) {
                        island_regexes_alloc = (island_regexes_alloc + 8) * 2;
-                       island_regexes = xrealloc(island_regexes,
-                                       island_regexes_alloc * sizeof(regex_t));
+                       REALLOC_ARRAY(island_regexes, island_regexes_alloc);
                }

                if (*v != '^')
@@ -425,7 +424,7 @@ static void deduplicate_islands(void)
        unsigned int island_count, dst, src, ref, i = 0;

        island_count = kh_size(remote_islands);
-       list = xmalloc(island_count * sizeof(struct remote_island *));
+       ALLOC_ARRAY(list, island_count);

        kh_foreach_value(remote_islands, island, {
                list[i++] = island;
Thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help