コード例 #1
0
ファイル: ml-cbr.c プロジェクト: HulaSamsquanch/1100d_lantern
static struct cbr_record * find_record(const char * event, unsigned int return_new) {
    ASSERT(event != NULL);
    struct cbr_record_arena * current = cbr_record_pool;
    struct cbr_record * first_free = NULL;
    while (current != NULL) {
        int i;
        for (i = 0; i < RECORD_POOL_SIZE; ++i) {
            if (current->pool[i].name[0] == '\0') {
                if (return_new && first_free == NULL) {
                    dbg_printf("Free record found @ %d\n", i);
                    first_free = &(current->pool[i]);
                }
            } else {
                if (fast_compare(event, current->pool[i].name)) {
                    return &(current->pool[i]);
                }
            }
        }
        current = current->next;
    }
    dbg_printf("No existing record found\n");
    if (first_free != NULL) {
        strncpy(first_free->name, event, 16);
        first_free->first = NULL;
        dbg_printf("%s\n", first_free->name);
    }
    return first_free;
}
コード例 #2
0
ファイル: utlrast.c プロジェクト: AnimatorPro/Animator-Pro
Boolean verify_raster(Raster *sr, Raster *vr, Boolean do_logging)
/*****************************************************************************
 * verify that contents of raster sr exactly match bytemap raster vr.
 *	(sr and vr have to have identical width/height!)
 ****************************************************************************/
{
	int 	errors;
	int 	x;
	int 	y;
	int 	width = sr->width;
	int 	height = sr->height;
	Pixel	*pvrastpix = vr->hw.bm.bp[0];
	Pixel	segbuf[2048];

	/*------------------------------------------------------------------------
	 * if there is a playback verify buffer allocated, that means our caller
	 * is the playback testing.  in this case, we know we don't need logging,
	 * and we suck in the whole hardware raster then do a single fast compare
	 * of the buffer with the bytemap raster.  if they're equal, we return
	 * TRUE right away.  if unequal, we fall into our line-at-a-time routine
	 * which will report the x/y locations of the errors.  if the playback
	 * routines can't get enough memory for the playback buffer, the slower
	 * loop will be used, so that either way the comparison gets done.
	 *----------------------------------------------------------------------*/

	if (tcb.playback_verify_buffer != NULL) {
		pj_get_rectpix(sr, tcb.playback_verify_buffer, 0, 0, width, height);
		if (fast_compare(tcb.playback_verify_buffer, pvrastpix, width*height))
			return TRUE;
	}

	/*------------------------------------------------------------------------
	 * if logging was requested, do it.
	 *----------------------------------------------------------------------*/

	if (do_logging) {
		char	*rastname;
		if (sr->type == RT_BYTEMAP)
			rastname = "bytemap";
		else if (sr == &tcb.display_raster)
			rastname = "primary display";
		else
			rastname = "secondary hardware";

		log_progress("   Verifying contents of %s raster...\n", rastname);
	}

	/*------------------------------------------------------------------------
	 * if we got a non-equal comparison in the monolithic fast_compare(),
	 * or if this isn't a playback test comparison, do a line-at-a-time
	 * comparison, and report the x/y locations of differences.
	 *----------------------------------------------------------------------*/

	errors = 0;

	for (y = 0; y < height; ++y, pvrastpix += width) {
		pj_get_hseg(sr, segbuf, 0, y, width);
		if (!fast_compare(segbuf, pvrastpix, width)) {
			for (x = 0; x < width; ++x) {
				if (pvrastpix[x] != segbuf[x]) {
					log_verror(x, y, segbuf[x], pvrastpix[x]);
					if (++errors >= 10)
						goto ERROR_EXIT;
				}
			}
		}
	}

	if (do_logging)
		if (errors == 0)
			log_progress("   ...verification complete.\n");

ERROR_EXIT:

	return (errors == 0);

}