The R Project SVN R

Rev

Rev 54330 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 54330 Rev 56956
Line 176... Line 176...
176
    c->obj = NULL;
176
    c->obj = NULL;
177
    c->old_bitmap = 0;
177
    c->old_bitmap = 0;
178
}
178
}
179
 
179
 
180
/*
180
/*
181
 *  Add a new DC into our list of DCs.
181
 *  Add a new DC into our list of DCs.  This is kind of ugly:  num_contexts just keeps growing, unless
-
 
182
 *  del_all_contexts is called, when it is set to 0.  The free ones will be scattered through the list.
182
 */
183
 */
183
PROTECTED
184
PROTECTED
184
void add_context(object obj, HDC dc, HGDIOBJ old)
185
void add_context(object obj, HDC dc, HGDIOBJ old)
185
{
186
{
186
    contextinfo *c;
187
    contextinfo *c;
187
 
188
 
188
    /* Clear a spot for the new DC if the array is full. */
189
    /* Search for or clear a spot for the new DC if the array is full. */
189
    if (num_contexts == MAX_CONTEXTS) {
190
    if (num_contexts == MAX_CONTEXTS) {
190
	c = & context[empty_slot];
191
        int i = empty_slot;
191
	free_context(c);
192
        while ( context[i].dc ) {
192
        /* Paul 2011-02-11
193
             i = (i+1) % MAX_CONTEXTS;
193
         * Improve search for next empty slot
194
             if (i == empty_slot) {
-
 
195
		 free_context(&context[i]);
194
         */
196
		 break;
195
        {
197
	     }
-
 
198
	}
196
            int old_empty = empty_slot;
199
        c = & context[i];
197
            empty_slot = (empty_slot+1) % MAX_CONTEXTS;
200
	empty_slot = (i+1) % MAX_CONTEXTS;
198
            while (context[empty_slot].dc) {
-
 
199
                empty_slot = (empty_slot+1) % MAX_CONTEXTS;
-
 
200
            }
-
 
201
            if (empty_slot == old_empty) {
-
 
202
                /* printf("Contexts exhausted; expect instability!"); */
-
 
203
            }
-
 
204
        }
-
 
205
    } else {
201
    } else {
206
	c = & context[num_contexts];
202
	c = & context[num_contexts];
207
	num_contexts++;
203
	num_contexts++;
208
    }
204
    }
209
    /* Add this context to the list. */
205
    /* Add this context to the list. */
Line 269... Line 265...
269
	c = & context[i];
265
	c = & context[i];
270
	if (c->obj == obj) {
266
	if (c->obj == obj) {
271
	    c->obj = NULL;
267
	    c->obj = NULL;
272
	    c->dc = 0;
268
	    c->dc = 0;
273
	    c->old_bitmap = 0;
269
	    c->old_bitmap = 0;
-
 
270
	    /* If we delete the last one, reduce the count:  avoid 
-
 
271
	       a search next time. */
-
 
272
	    if (i == num_contexts - 1)
-
 
273
	    	num_contexts--;
-
 
274
	    else
274
	    empty_slot = i;
275
	    	empty_slot = i;
275
	}
276
	}
276
    }
277
    }
277
}
278
}
278
 
279
 
279
/*
280
/*
Line 290... Line 291...
290
	if (c->obj == obj) {
291
	if (c->obj == obj) {
291
	    free_context(c);
292
	    free_context(c);
292
	    c->obj = NULL;
293
	    c->obj = NULL;
293
	    c->dc = 0;
294
	    c->dc = 0;
294
	    c->old_bitmap = 0;
295
	    c->old_bitmap = 0;
-
 
296
	    /* If we delete the last one, reduce the count:  avoid 
-
 
297
	       a search next time. */
-
 
298
	    if (i == num_contexts - 1)
-
 
299
	    	num_contexts--;
-
 
300
	    else
295
	    empty_slot = i;
301
	    	empty_slot = i;
-
 
302
 
296
	}
303
	}
297
    }
304
    }
298
}
305
}
299
 
306
 
300
/*
307
/*