Beispiel #1
0
void add_to_cache(int track)
{
	if (num_cache_entries == 0) {
		if (cache_size > 0) {
			cache_head = cache_tail = cache_allocate( track );
			num_cache_entries++;
			return;
		} else
			return;
	}

	cache_head->next = cache_allocate( track );
	cache_head->next->prev = cache_head;
	cache_head = cache_head->next;

	if (num_cache_entries == cache_size) {
		Cache_entry *temp;
		temp = cache_tail;
		cache_tail = cache_tail->next;
		cache_tail->prev = NULL;
		free(temp);
	} else
		num_cache_entries++;
}
Beispiel #2
0
void decompose_rom_sample_path (char *rompath, char *samplepath)
{
	rompathc    = path2vector (rompath,    buf1, rompathv);
	samplepathc = path2vector (samplepath, buf2, samplepathv);

#ifdef FILE_CACHE
	/* AM 980919 */
	if (file_cache_max == 0) {
		/* (rom path directories + 1 buffer)==rompathc+1 */
		/* (dir + .zip + .zif)==3 */
		/* (clone+parent)==2 */
		cache_allocate((rompathc+1)*3*2);
	}
#endif

}
Beispiel #3
0
/* This function can be called several times with different parameters,
 * for example by "mame -verifyroms *". */
void decompose_rom_sample_path (char *rompath, char *samplepath)
{
	char *token;

	/* start with zero path components */
	rompathc = samplepathc = 0;

	if (!roms)
		roms = (char*)malloc( strlen(rompath) + 1);
	else
		roms = (char*)realloc( roms, strlen(rompath) + 1);

	if (!samples)
		samples = (char*)malloc( strlen(samplepath) + 1);
	else
		samples = (char*)realloc( samples, strlen(samplepath) + 1);

	if( !roms || !samples )
	{
		logerror("decompose_rom_sample_path: failed to malloc!\n");
		raise(SIGABRT);
	}

	strcpy (roms, rompath);
	token = strtok (roms, ";");
	while( token )
	{
		if( rompathc )
			rompathv = (char**)realloc(rompathv, (rompathc + 1) * sizeof(char *));
		else
			rompathv = (char**)malloc(sizeof(char *));
		if( !rompathv )
			break;
		rompathv[rompathc++] = token;
		token = strtok (NULL, ";");
	}

	strcpy (samples, samplepath);
	token = strtok (samples, ";");
	while( token )
	{
		if( samplepathc )
			samplepathv = (char**)realloc(samplepathv, (samplepathc + 1) * sizeof(char *));
		else
			samplepathv = (char**)malloc(sizeof(char *));
		if( !samplepathv )
			break;
		samplepathv[samplepathc++] = token;
		token = strtok (NULL, ";");
	}

#if FILE_CACHE
    /* AM 980919 */
    if( file_cache_max == 0 )
    {
        /* (rom path directories + 1 buffer)==rompathc+1 */
        /* (dir + .zip + .zif)==3 */
        /* (clone+parent)==2 */
        cache_allocate ((rompathc + 1) * 3 * 2);
    }
#endif

}