Module Name: src Committed By: macallan Date: Tue Nov 13 20:29:03 UTC 2012
Modified Files: src/sys/dev/wscons: wsdisplay_glyphcache.c Log Message: glyphcache_init(): bail if we don't have enough off-screen memory to be useful To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/wscons/wsdisplay_glyphcache.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/wscons/wsdisplay_glyphcache.c diff -u src/sys/dev/wscons/wsdisplay_glyphcache.c:1.4 src/sys/dev/wscons/wsdisplay_glyphcache.c:1.5 --- src/sys/dev/wscons/wsdisplay_glyphcache.c:1.4 Thu Oct 4 10:26:32 2012 +++ src/sys/dev/wscons/wsdisplay_glyphcache.c Tue Nov 13 20:29:03 2012 @@ -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 @@ glyphcache_init(glyphcache *gc, int firs 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__);