Ejemplo n.º 1
0
Arbol _nuevo_nodo(Constructor constructor)
{
 Arbol p;

 p = (Arbol)Memory_Alloc(sizeof(struct s_arbol));
 if (p == NULL) fprintf(stderr, "Se acab¢ la memoria\n"), exit(2);
 p->hermano = NULL;
 p->hijos = NULL;
 p->padre = NULL;
 p->clon = 0;
 p->clonado = 0;
 p->info = Memory_Alloc(sizeof(T_info));
 p->info->refno = 0;
 p->info->constructor = constructor;
 return(p);
}
Ejemplo n.º 2
0
Dictionary_Entry_Value* Dictionary_Entry_Value_FromString( const char* const value ) {
	Dictionary_Entry_Value* self = Memory_Alloc( Dictionary_Entry_Value, "Entry Value String" );
	
	Dictionary_Entry_Value_InitFromString( self, value );
	
	return self;
}
Ejemplo n.º 3
0
Dictionary_Entry_Value* Dictionary_Entry_Value_FromDouble( double value ) {
	Dictionary_Entry_Value* self = Memory_Alloc( Dictionary_Entry_Value, "Entry Value Double" );
	
	Dictionary_Entry_Value_InitFromDouble( self, value );
	
	return self;
}
Ejemplo n.º 4
0
Dictionary_Entry_Value* Dictionary_Entry_Value_FromInt( int value ) {
	Dictionary_Entry_Value* self = Memory_Alloc( Dictionary_Entry_Value, "Entry Value Int" );
	
	Dictionary_Entry_Value_InitFromInt( self, value );
	
	return self;
}
Ejemplo n.º 5
0
Dictionary_Entry_Value* Dictionary_Entry_Value_FromStruct( void* dictionary )
{
	Dictionary_Entry_Value* self = Memory_Alloc( Dictionary_Entry_Value, "Entry Value Struct" );
	
	Dictionary_Entry_Value_InitFromStruct( self, dictionary );
	return self;
}
Ejemplo n.º 6
0
Dictionary_Entry_Value* Dictionary_Entry_Value_FromUnsignedInt( unsigned int value ) {
	Dictionary_Entry_Value* self = Memory_Alloc( Dictionary_Entry_Value, "Entry Value Signed Int" );
	
	Dictionary_Entry_Value_InitFromUnsignedInt( self, value );
	
	return self;
}
Ejemplo n.º 7
0
Dictionary_Entry_Value* Dictionary_Entry_Value_NewList( void )
{
	Dictionary_Entry_Value* self = Memory_Alloc( Dictionary_Entry_Value, "Entry Value List" );
	
	Dictionary_Entry_Value_InitNewList( self );
	return self;
}
Ejemplo n.º 8
0
Dictionary_Entry_Value* Dictionary_Entry_Value_FromUnsignedLong( unsigned long value ) {
	Dictionary_Entry_Value* self = Memory_Alloc( Dictionary_Entry_Value, "Entry Value Unsigned Long" );
	
	Dictionary_Entry_Value_InitFromUnsignedLong( self, value );
	
	return self;
}
Ejemplo n.º 9
0
Dictionary_Entry_Value* Dictionary_Entry_Value_FromBool( Bool value ) {
	Dictionary_Entry_Value* self = Memory_Alloc( Dictionary_Entry_Value, "Entry Value Bool" );
	
	Dictionary_Entry_Value_InitFromBool( self, value );
	
	return self;
}
Ejemplo n.º 10
0
//-----------------------------------------------------------------------------
// DB_Name_New (t_db_entry *, char *name, int country, int non_latin)
// Create and initialize a new DB Name, then add into a DB Entry
//-----------------------------------------------------------------------------
t_db_name *     DB_Name_New (t_db_entry *entry, char *name, int country, int non_latin)
{
    t_db_name* dbname = (t_db_name*)Memory_Alloc(sizeof (t_db_name));

    // Initialize
    dbname->name        = name;
    dbname->country     = country;
    dbname->non_latin   = non_latin;
    dbname->next        = NULL;

    // Add at end of entry chained list (Note: this is a relatively slow operation)
    if (entry->names == NULL)
    {
        entry->names = dbname;
    }
    else
    {
        t_db_name *previous = entry->names;
        while (previous->next != NULL)
            previous = previous->next;
        previous->next = dbname;
    }

    return (dbname);
}
Ejemplo n.º 11
0
//-----------------------------------------------------------------------------
// DB_Entry_New (int system, u32 crc32, t_meka_crc *mekacrc)
// Create and initialize a new DB entry
//-----------------------------------------------------------------------------
t_db_entry *    DB_Entry_New (int system, u32 crc32, t_meka_crc *mekacrc)
{
    t_db_entry * entry = (t_db_entry *)Memory_Alloc(sizeof (t_db_entry));

    // Initialize
    entry->system       = system;
    entry->crc_crc32    = crc32;
    entry->crc_mekacrc  = *mekacrc;
    entry->names        = NULL;
    entry->country      = 0;
    entry->flags        = 0;
    entry->product_no   = NULL;
    entry->version      = NULL;
    entry->comments     = NULL;
    entry->authors      = NULL;
    entry->trans_country= -1;
    entry->emu_country  = -1;
    entry->emu_inputs   = -1;
    entry->emu_iperiod  = -1;
    entry->emu_mapper   = -1;
    entry->emu_tvtype   = -1;
    entry->emu_vdp_model= -1;

    return (entry);
}
Ejemplo n.º 12
0
static void Dictionary_Entry_Value_SetValueNewList( Dictionary_Entry_Value* self )
{
	self->as.typeList = Memory_Alloc( Dictionary_Entry_Value_List, "Entry Value List" );
	self->as.typeList->first = NULL;
	self->as.typeList->last = NULL;
	self->as.typeList->count = 0;
	self->as.typeList->encoding = Default;
	self->type = Dictionary_Entry_Value_Type_List;
}
Ejemplo n.º 13
0
// Initialize Sound Card ------------------------------------------------------
static  int     Sound_Init_SoundCard (void)
{
  int            i;
  AUDIOINFO      Audio_Infos;

  ConsolePrintf (Msg_Get (MSG_Sound_Init_Soundcard), Sound.SampleRate);
  ConsolePrint ("\n");

  Audio_Infos.nDeviceId = Sound.SoundCard;
  Audio_Infos.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO; // FIXME: Stereo ?
  Audio_Infos.nSampleRate = audio_sample_rate = Sound.SampleRate;

  if (AOpenAudio(&Audio_Infos) != AUDIO_ERROR_NONE)
     {
     Quit_Msg ("%s", Msg_Get (MSG_Sound_Init_Error_Audio));
     return (MEKA_ERR_FAIL);
     }
  // FIXME: original sound engine was trying different sample rate on failure

  // Unused
  // Maybe it was intended to check out number of channels there ?
  // AGetAudioCaps (Audio_Infos.nDeviceId, &Audio_Caps);

  // Open voices
  if (AOpenVoices(Sound.Voices_Max) != AUDIO_ERROR_NONE)
     {
     Quit_Msg ("%s", Msg_Get (MSG_Sound_Init_Error_Voices));
     return (MEKA_ERR_FAIL);
     }

  ASetAudioMixerValue (AUDIO_MIXER_MASTER_VOLUME, 256);

  // Allocate voices and waveforms
  Sound.Voices = Memory_Alloc (sizeof (t_voice) * Sound.Voices_Max);
  for (i = 0; i < Sound.Voices_Max; i++)
     {
     if (ACreateAudioVoice(&Sound.Voices[i].hVoice) != AUDIO_ERROR_NONE)
        {
        Quit_Msg (Msg_Get (MSG_Sound_Init_Error_Voice_N), i);
        return (MEKA_ERR_FAIL);
        }
     ASetVoicePanning(Sound.Voices[i].hVoice, 128); // Center voice
     Sound.Voices[i].lpWave  = NULL;
     Sound.Voices[i].playing = FALSE;
     }

  // FIXME: is this needed ?
  AUpdateAudio ();

  // FIXME: is this needed ?
  // Check frame sample rate
  audio_sample_rate = nominal_sample_rate = Audio_Infos.nSampleRate;

  return (MEKA_ERR_OK);
}
StreamFormatter_Buffer* StreamFormatter_Buffer_New() {
	StreamFormatter_Buffer* result = Memory_Alloc( StreamFormatter_Buffer, "StreamFormatter_Buffer" );
	result->buffer1 = NULL;
	result->buffer2 = NULL;
	result->length1 = 0;
	result->length2 = 0;
	result->current = &result->buffer1;
	result->lengthPtr = &result->length1;

	return result;
}
Ejemplo n.º 15
0
Symbol_Table *Symbol_Table_Create(string name, unsigned num_of_entries)
{
  Symbol_Table *result;

  assert(name != NULL);

  result = (Symbol_Table *)Memory_Alloc(sizeof(Symbol_Table));
  result->name = name;
  result->pool = Hash_Table_Create(num_of_entries, Aho_Hash, (Destructor)Memory_Free);
  /*-result->pool = Hash_Table_Create(num_of_entries, Aho_Hash, (Destructor)Symbol_Free); */

  return result;
}
Ejemplo n.º 16
0
Dictionary_Entry_Value* Dictionary_Entry_Value_FromStringTo( char* string, char type ) {
	Dictionary_Entry_Value* retValue = Memory_Alloc( Dictionary_Entry_Value, "Return Value" );
	
	/* need to create the value temporarily so it can be converted if necessary */
	retValue->type = Dictionary_Entry_Value_Type_String;

	if ( string ) {
		retValue->as.typeString = ExpandEnvironmentVariables( string );
	}
	else {
		retValue->as.typeString = string;
	}
	
	switch (type) {
		case Dictionary_Entry_Value_Type_String:
			Dictionary_Entry_Value_InitFromString( retValue, retValue->as.typeString );
			break;
		case Dictionary_Entry_Value_Type_Double:
			Dictionary_Entry_Value_InitFromDouble( retValue, Dictionary_Entry_Value_AsDouble( retValue ) );
			break;
		case Dictionary_Entry_Value_Type_UnsignedInt:
			Dictionary_Entry_Value_InitFromUnsignedInt( retValue, Dictionary_Entry_Value_AsUnsignedInt( retValue ) );
			break;
		case Dictionary_Entry_Value_Type_Int:
			Dictionary_Entry_Value_InitFromInt( retValue, Dictionary_Entry_Value_AsInt( retValue ) );
			break;
		case Dictionary_Entry_Value_Type_UnsignedLong:
			Dictionary_Entry_Value_InitFromUnsignedLong( retValue, Dictionary_Entry_Value_AsUnsignedLong( retValue ) );
			break;
		case Dictionary_Entry_Value_Type_Bool:
			Dictionary_Entry_Value_InitFromBool( retValue, Dictionary_Entry_Value_AsBool( retValue ) );
			break;
		case Dictionary_Entry_Value_Type_Struct:
			Dictionary_Entry_Value_InitNewStruct( retValue );
			break;
		case Dictionary_Entry_Value_Type_List:
			Dictionary_Entry_Value_InitNewList( retValue );
			break;
		default: {
			Stream* errorStream = Journal_Register( Error_Type, "Dictionary_Entry_Value" );
			Journal_Firewall( False, errorStream, "In func %s: type '%d' is invalid.\n", __func__, type );
		}
	}		
	
	return retValue;
}
Ejemplo n.º 17
0
static void        ConsoleWin32_Print(t_console_win32 *c, char *s)
{
    char *  text;
    int     text_length;
    int     newlines_counter;

    if (c->hwnd == 0)
        return;

    // Count '\n' in new text
    newlines_counter = 0;
    for (text = s; *text != EOSTR; text++)
        if (*text == '\n')
            newlines_counter++;

    // Fill text buffer
    // Replace all occurences single "\n" by "\r\n" since windows edit box wants that
    text = (char*)Memory_Alloc(strlen(s) + (newlines_counter * sizeof(char)) + 2 + 1);
    {
        char* dst = text;
        while (*s != EOSTR)
        {
            if (*s == '\n')
                *dst++ = '\r';
            *dst++ = *s++;
        }
        *dst = EOSTR;
        //  sprintf(text + text_length, "%s", s);
    }

    // Set new text
    // Tips: set an empty selection at the end then replace selection, to avoid flickering (better than a WM_SETTEXT)
    text_length = GetWindowTextLength(c->hwnd_edit);
    SendMessage(c->hwnd_edit, EM_SETSEL, text_length, text_length);
    SendMessage(c->hwnd_edit, EM_REPLACESEL, FALSE, (LPARAM)text);
    free(text);
}
Ejemplo n.º 18
0
void			Cli_Init( void )
{
	U16	i;
	

	for( i=0; i<dCLI_CMD_LIMIT; i++ )
	{
		gCliCommand[ i ].pCommandString = 0;
		gCliCommand[ i ].fCommand       = 0;
		gCliCommand[ i ].pHelpTxt       = 0;
	}

	for( i=0; i<dCLI_HISTORY_LIMIT; i++ )
	{
		Cli_StringClear( &gCliHistoryLine[ i ][ 0 ] );
	}

	for( i=0; i<dCLI_DISPLAYLINES_LIMIT; i++ )
	{
		Cli_StringClear( &gCliDisplayLine[ i ][ 0 ] );
	}

	Cli_StringClear( &gCliCurrentLine[ 0 ] );
	Cli_StringClear( &gCliTabStub[ 0 ] );

	gCliCursorX           = 0;
	gCliCurrentLineIndex  = 0;
	gCliDisplayLineIndex  = 0;
	gCliDisplayLoopedFlag = 0;
	gCliHistoryLineIndex  = 0;
	gCliHistoryLoopedFlag = 0;
	gCliCommandCount      = 0;
	gCliTabIndex          = 0;
	gCliTabbingFlag       = 0;

	gpCliSavedScreen = Memory_Alloc( 32000L );
}