Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/wscons glyphcache_init(): bail if we don't have enou...



details:   https://anonhg.NetBSD.org/src/rev/ed3c8885b3d7
branches:  trunk
changeset: 782675:ed3c8885b3d7
user:      macallan <macallan%NetBSD.org@localhost>
date:      Tue Nov 13 20:29:03 2012 +0000

description:
glyphcache_init(): bail if we don't have enough off-screen memory to be useful

diffstat:

 sys/dev/wscons/wsdisplay_glyphcache.c |  10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diffs (24 lines):

diff -r 03576409018f -r ed3c8885b3d7 sys/dev/wscons/wsdisplay_glyphcache.c
--- a/sys/dev/wscons/wsdisplay_glyphcache.c     Tue Nov 13 20:10:02 2012 +0000
+++ b/sys/dev/wscons/wsdisplay_glyphcache.c     Tue Nov 13 20:29:03 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsdisplay_glyphcache.c,v 1.4 2012/10/04 10:26:32 macallan Exp $        */
+/*     $NetBSD: wsdisplay_glyphcache.c,v 1.5 2012/11/13 20:29:03 macallan Exp $        */
 
 /*
  * Copyright (c) 2012 Michael Lorenz
@@ -75,6 +75,14 @@
        buckets = (gc->gc_numcells / 223);
        if ((buckets * 223) < gc->gc_numcells)
                buckets++;
+
+       /*
+        * if we don't have enough video memory to cache at least a few glyphs
+        * we stop right here
+        */
+       if (buckets < 1)
+               return ENOMEM;
+
        gc->gc_buckets = kmem_alloc(sizeof(gc_bucket) * buckets, KM_SLEEP);
        if (gc->gc_buckets == NULL) {
                aprint_error("%s: can't allocate memory\n", __func__);



Home | Main Index | Thread Index | Old Index