bool_t AllocBlock(size_t n,block* Block,bool_t Optional,int Heap) { void* p; if (Optional && AvailMemory() < (256+64)*1024+n) // we want to avoid OS low memory warning return 0; #ifdef BLOCKGROUP if (n == BLOCKSIZE && AllocBlockGroup(Block,Optional)) return 1; #endif do { p = malloc(n); if (p) { Block->Ptr = p; Block->Id = 0; return 1; } } while (!p && !Optional && n && NodeHibernate()); Block->Ptr = p; Block->Id = 0; #ifndef NDEBUG if (p) ++BlockAllocated; #endif return p!=NULL; }
bool_t Context_Init(const tchar_t* Name,const tchar_t* Version,int Id,const tchar_t* CmdLine,void* Application) { context* p = malloc(sizeof(context)); if (!p) return 0; #ifdef PREALLOC { int i; for (i=0;i<PREALLOC;++i) q[i] = malloc(65536); } #endif memset(p,0,sizeof(context)); p->Version = CONTEXT_VERSION; p->ProgramId = Id; p->ProgramName = Name; p->ProgramVersion = Version; p->CmdLine = CmdLine; p->Lang = DefaultLang(); p->StartUpMemory = AvailMemory(); p->LowMemory = p->StartUpMemory < LOWMEMORY_LIMIT; p->Application = Application; SetContext(p); Mem_Init(); DynCode_Init(); String_Init(); PCM_Init(); Blit_Init(); Node_Init(); Platform_Init(); Stream_Init(); Advanced_Init(); Flow_Init(); Codec_Init(); Audio_Init(); Video_Init(); Format_Init(); Playlist_Init(); FormatBase_Init(); NullOutput_Init(); RawAudio_Init(); RawImage_Init(); Timer_Init(); IDCT_Init(); Overlay_Init(); M3U_Init(); PLS_Init(); ASX_Init(); WaveOut_Init(); SoftIDCT_Init(); #if defined(CONFIG_SUBS) SubTitle_Init(); #endif #if defined(TARGET_PALMOS) OverlayHIRES_Init(); //Win_Init(); //About_Init(); //BenchResult_Init(); //MediaInfo_Init(); //Settings_Init(); ASF_Init(); AVI_Init(); WAV_Init(); MP4_Init(); MPG_Init(); NSV_Init(); Law_Init(); ADPCM_Init(); #elif defined(TARGET_WIN32) || defined(TARGET_WINCE) #if defined(TARGET_WINCE) if (QueryPlatform(PLATFORM_TYPENO) != TYPE_SMARTPHONE) { OverlayRAW_Init(); OverlayGAPI_Init(); } else { OverlayGAPI_Init(); // prefer GAPI with smartphones (Sagem MyS-7 crashes with Raw FrameBuffer?) OverlayRAW_Init(); } OverlayDirect_Init(); OverlayS1D13806_Init(); #else OverlayConsole_Init(); #endif OverlayXScale_Init(); OverlayDDraw_Init(); // after GAPI and RAW and XScale OverlayFlyTV_Init(); OverlayGDI_Init(); #elif defined(TARGET_SYMBIAN) OverlaySymbian_Init(); #endif #ifdef NO_PLUGINS Static_Init(); #else Plugins_Init(); #endif Association_Init(); // after all formats are registered Color_Init(); Equalizer_Init(); Player_Init(); // after all output drivers are registered return 1; }