]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use newa() rather than alloca() where we can
authorLennart Poettering <lennart@poettering.net>
Fri, 27 Apr 2018 12:28:35 +0000 (14:28 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 27 Apr 2018 12:29:06 +0000 (14:29 +0200)
src/basic/calendarspec.c
src/basic/process-util.c
src/cgtop/cgtop.c
src/journal/journal-file.c
src/journal/journal-send.c
src/test/test-condition.c

index 24867f807b662ba64fb4ea3b649f6b36569f11c9..a30de78dc233ed9931a095caddc89644a7274317 100644 (file)
@@ -104,7 +104,7 @@ static void normalize_chain(CalendarComponent **c) {
         if (n <= 1)
                 return;
 
-        j = b = alloca(sizeof(CalendarComponent*) * n);
+        j = b = newa(CalendarComponent*, n);
         for (i = *c; i; i = i->next)
                 *(j++) = i;
 
index 960920d3ddb1d344e7757a963b9b30c9081ab4ed..4180769ee8da3441c07f8f979cb369297c4c7a8f 100644 (file)
@@ -1433,7 +1433,7 @@ int fork_agent(const char *name, const int except[], size_t n_except, pid_t *ret
         va_end(ap);
 
         /* Allocate strv */
-        l = alloca(sizeof(char *) * (n + 1));
+        l = newa(char*, n + 1);
 
         /* Fill in arguments */
         va_start(ap, path);
index de5083bddea031c83199331e5d3ceb9fbaefe86a..de7ecf54cda902df4f4369996601aec5bcf77324 100644 (file)
@@ -627,7 +627,7 @@ static void display(Hashmap *a) {
         if (!terminal_is_dumb())
                 fputs(ANSI_HOME_CLEAR, stdout);
 
-        array = alloca(sizeof(Group*) * hashmap_size(a));
+        array = newa(Group*, hashmap_size(a));
 
         HASHMAP_FOREACH(g, a, i)
                 if (g->n_tasks_valid || g->cpu_valid || g->memory_valid || g->io_valid)
index 07c25abb89805721d266a6dc8d4b475d618c2cda..036594c7350ce847affda7d526bffb889f07fdb8 100644 (file)
@@ -1965,7 +1965,7 @@ int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const st
 #endif
 
         /* alloca() can't take 0, hence let's allocate at least one */
-        items = alloca(sizeof(EntryItem) * MAX(1u, n_iovec));
+        items = newa(EntryItem, MAX(1u, n_iovec));
 
         for (i = 0; i < n_iovec; i++) {
                 uint64_t p;
@@ -3581,7 +3581,7 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
 
         n = journal_file_entry_n_items(o);
         /* alloca() can't take 0, hence let's allocate at least one */
-        items = alloca(sizeof(EntryItem) * MAX(1u, n));
+        items = newa(EntryItem, MAX(1u, n));
 
         for (i = 0; i < n; i++) {
                 uint64_t l, h;
index 0da07a1941ee6a9660d7b80180ca415e6cb36812..e0526a02ca5e314a7b83f23ab528d332583f593c 100644 (file)
@@ -518,7 +518,7 @@ _public_ int sd_journal_sendv_with_location(
         assert_return(iov, -EINVAL);
         assert_return(n > 0, -EINVAL);
 
-        niov = alloca(sizeof(struct iovec) * (n + 3));
+        niov = newa(struct iovec, (n + 3));
         memcpy(niov, iov, sizeof(struct iovec) * n);
 
         ALLOCA_CODE_FUNC(f, func);
index 18f325f72f0c868906423dc5739d0250f534a321..eeea778679f621c9db0202e4abe9b13f0baccb26 100644 (file)
@@ -608,7 +608,7 @@ static void test_condition_test_group(void) {
         ngroups_max = sysconf(_SC_NGROUPS_MAX);
         assert(ngroups_max > 0);
 
-        gids = alloca(sizeof(gid_t) * ngroups_max);
+        gids = newa(gid_t, ngroups_max);
 
         ngroups = getgroups(ngroups_max, gids);
         assert(ngroups >= 0);