Replace an alloca use with a variable-length array.
authorRoland McGrath <roland@hack.frob.com>
Tue, 5 Feb 2013 20:15:56 +0000 (12:15 -0800)
committerRoland McGrath <roland@hack.frob.com>
Tue, 5 Feb 2013 20:15:56 +0000 (12:15 -0800)
ChangeLog
elf/dl-hwcaps.c

index 1661df9b6f3143fdc4413c7d155c4b411d37b785..818edb4862eca87e02783675198485c23f473468 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2013-02-05  Roland McGrath  <roland@hack.frob.com>
 
+       * elf/dl-hwcaps.c (_dl_important_hwcaps): Use a variable-length array
+       instead of calling alloca.
+
        * io/lseek.c (__lseek): Rename to __libc_lseek.
        Define __lseek as an alias.
 
index 3805949e8afe90e7c7553987bfc870bf16b40bd3..d3214e5dc490a55fa36dc62246fc646185cec0d5 100644 (file)
@@ -42,7 +42,6 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
   size_t cnt = platform != NULL;
   size_t n, m;
   size_t total;
-  struct r_strlenpair *temp;
   struct r_strlenpair *result;
   struct r_strlenpair *rp;
   char *cp;
@@ -103,7 +102,7 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
   ++cnt;
 
   /* Create temporary data structure to generate result table.  */
-  temp = (struct r_strlenpair *) alloca (cnt * sizeof (*temp));
+  struct r_strlenpair temp[cnt];
   m = 0;
 #if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
   if (dsocaps != NULL)
@@ -199,7 +198,7 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
     }
 
   /* Fill in the information.  This follows the following scheme
-     (indeces from TEMP for four strings):
+     (indices from TEMP for four strings):
        entry #0: 0, 1, 2, 3    binary: 1111
              #1: 0, 1, 3               1101
              #2: 0, 2, 3               1011