Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/librump/rumpkern Emulate malloc(9) a little better ...
details: https://anonhg.NetBSD.org/src/rev/2c025128d92b
branches: trunk
changeset: 756184:2c025128d92b
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Jul 08 11:39:58 2010 +0000
description:
Emulate malloc(9) a little better by panicking if a should-not-fail
allocation fails. We could invoke the pagedaemon here, but since
malloc(9) is panicky when it runs out of kmem_map, let's do the
"same".
diffstat:
sys/rump/librump/rumpkern/memalloc.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diffs (29 lines):
diff -r df4c6685a85a -r 2c025128d92b sys/rump/librump/rumpkern/memalloc.c
--- a/sys/rump/librump/rumpkern/memalloc.c Thu Jul 08 11:24:59 2010 +0000
+++ b/sys/rump/librump/rumpkern/memalloc.c Thu Jul 08 11:39:58 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: memalloc.c,v 1.9 2010/06/14 21:04:56 pooka Exp $ */
+/* $NetBSD: memalloc.c,v 1.10 2010/07/08 11:39:58 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.9 2010/06/14 21:04:56 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.10 2010/07/08 11:39:58 pooka Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -74,6 +74,10 @@
void *rv;
rv = rumpuser_malloc(size, 0);
+
+ if (__predict_false(rv == NULL && (flags & (M_CANFAIL|M_NOWAIT)) == 0))
+ panic("malloc %lu bytes failed", size);
+
if (rv && flags & M_ZERO)
memset(rv, 0, size);
Home |
Main Index |
Thread Index |
Old Index