variable length arrays.
Saves 50 bytes on compressed image.
+2013-10-20 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * grub-core/kern/disk.c (grub_disk_write): Use malloc/free instead of
+ variable length arrays.
+
+ Saves 50 bytes on compressed image.
+
2013-10-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/bsd.c: Remove variable length arrays.
if (real_offset != 0 || (size < (1U << disk->log_sector_size)
&& size != 0))
{
- char tmp_buf[1 << disk->log_sector_size];
+ char *tmp_buf;
grub_size_t len;
grub_partition_t part;
+ tmp_buf = grub_malloc (1 << disk->log_sector_size);
+ if (!tmp_buf)
+ return grub_errno;
+
part = disk->partition;
disk->partition = 0;
if (grub_disk_read (disk, sector,
!= GRUB_ERR_NONE)
{
disk->partition = part;
+ grub_free (tmp_buf);
goto finish;
}
disk->partition = part;
if ((disk->dev->write) (disk, transform_sector (disk, sector),
1, tmp_buf) != GRUB_ERR_NONE)
- goto finish;
+ {
+ grub_free (tmp_buf);
+ goto finish;
+ }
+
+ grub_free (tmp_buf);
sector += (1 << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS));
buf = (const char *) buf + len;