grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 2/3] efidisk: implement alignment-respecting malloc function


From: Leif Lindholm
Subject: [PATCH v2 2/3] efidisk: implement alignment-respecting malloc function
Date: Wed, 2 Mar 2016 00:14:11 +0000

Implement a driver-specific malloc function that allocates a buffer
with the alignment specified by grub_efi_block_io_media structure.
---
 grub-core/disk/efi/efidisk.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index 3b79f7b..ac99ea7 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -457,6 +457,13 @@ get_device (struct grub_efidisk_data *devices, int num)
   return 0;
 }
 
+static void *
+aligned_malloc (struct grub_disk *disk, grub_size_t size)
+{
+  struct grub_efidisk_data *d = disk->data;
+  return grub_memalign (d->block_io->media->io_align, size);
+}
+
 static grub_err_t
 grub_efidisk_open (const char *name, struct grub_disk *disk)
 {
@@ -512,6 +519,7 @@ grub_efidisk_open (const char *name, struct grub_disk *disk)
        (1U << disk->log_sector_size) < m->block_size;
        disk->log_sector_size++);
   disk->data = d;
+  disk->malloc = aligned_malloc;
 
   grub_dprintf ("efidisk", "opening %s succeeded\n", name);
 
-- 
2.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]