[429] in BarnOwl Developers
[D-O-H] r560 - trunk/owl
daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:06:03 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Wed, 24 Jan 2007 02:23:32 -0500 (EST)
Author: asedeno
Date: 2007-01-24 02:23:32 -0500 (Wed, 24 Jan 2007)
New Revision: 560
Modified:
trunk/owl/fmtext.c
Log:
Further simplifications.
Modified: trunk/owl/fmtext.c
===================================================================
--- trunk/owl/fmtext.c 2007-01-24 05:18:11 UTC (rev 559)
+++ trunk/owl/fmtext.c 2007-01-24 07:23:32 UTC (rev 560)
@@ -662,8 +662,7 @@
{
// This could be a bitarray if we wanted to save memory.
int i, j, colors;
- cpmgr->used = owl_malloc(COLOR_PAIRS * sizeof(char));
- memset(cpmgr->used, 0, COLOR_PAIRS * sizeof(char));
+ cpmgr->next = COLORS;
colors = COLORS + 1; // 1 to account for "default".
cpmgr->pairs = owl_malloc(colors * sizeof(int*));
@@ -682,7 +681,7 @@
{
int i, j, colors;
owl_colorpair_mgr *cpmgr = owl_global_get_colorpair_mgr(&g);
- memset(cpmgr->used, 0, COLOR_PAIRS * sizeof(char));
+ cpmgr->next = COLORS;
colors = COLORS + 1; // 1 to account for "default".
for(i = 0; i < colors; i++) {
@@ -714,22 +713,16 @@
// looking for a pair we already set up for this draw.
cpmgr = owl_global_get_colorpair_mgr(&g);
pair = cpmgr->pairs[fg+1][bg];
- if (!(pair != -1 && cpmgr->used[pair])) {
+ if (!(pair != -1 && pair < cpmgr->next)) {
// If we didn't find a pair, search for a free one to assign.
// Skip the first COLORS, since they're static.
// If we ever get 256 color curses, this will need more thought.
- for(i = COLORS; i < COLOR_PAIRS; i++) {
- if (!cpmgr->used[i]) {
- // Found a free pair
- pair = i;
- break;
- }
- }
+ pair = (cpmgr->next < COLOR_PAIRS) ? cpmgr->next : -1;
if (pair != -1) {
// We found a free pair, initialize it.
init_pair(pair, fg, bg);
cpmgr->pairs[fg+1][bg] = pair;
- cpmgr->used[pair] = 1;
+ cpmgr->next++;
} else {
// We still don't have a pair, drop the background color. Too bad.
pair = fg;