pkgsrc-wip/grub2/patches/patch-ak

28 lines
778 B
Text
Raw Normal View History

$NetBSD: patch-ak,v 1.5 2007/11/20 05:56:10 bsadewitz Exp $
2005-12-12 18:42:17 +01:00
--- util/misc.c.orig 2007-10-21 08:29:33.000000000 -0400
2006-01-13 15:16:17 +01:00
+++ util/misc.c
@@ -36,6 +36,9 @@
memalign is declared in malloc.h in all systems, if present. */
#ifdef HAVE_MEMALIGN
# include <malloc.h>
+# if !defined(posix_memalign) && defined(__NetBSD__)
+int posix_memalign(void **memptr, size_t alignment, size_t size);
+# endif
#endif
char *progname = 0;
@@ -242,7 +245,11 @@ grub_memalign (grub_size_t align, grub_s
#elif defined(HAVE_MEMALIGN)
p = memalign (align, size);
#else
- grub_util_error ("grub_memalign is not supported");
2006-01-13 15:16:17 +01:00
+ p = malloc (size + align - 1);
+ if (p)
+ p = (void *)(((int)p/align + 1) * align);
+ else
+ grub_util_error ("out of memory");
#endif
if (! p)