mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-10 09:40:53 +01:00
Change ConfigsList from statically allocated to XStringWArray.
This commit is contained in:
parent
9c79b8f1c5
commit
8134f37bde
@ -89,8 +89,7 @@ EFI_EDID_DISCOVERED_PROTOCOL *EdidDiscovered;
|
||||
|
||||
|
||||
XStringWArray ThemeNameArray;
|
||||
UINTN ConfigsNum;
|
||||
CHAR16 *ConfigsList[20];
|
||||
XStringWArray ConfigsList;
|
||||
UINTN DsdtsNum = 0;
|
||||
CHAR16 *DsdtsList[20];
|
||||
XObjArray<HDA_OUTPUTS> AudioList;
|
||||
|
@ -2748,10 +2748,9 @@ public:
|
||||
extern XObjArray<HDA_OUTPUTS> AudioList;
|
||||
|
||||
extern XStringWArray ThemeNameArray;
|
||||
extern CHAR16* ConfigsList[20];
|
||||
extern XStringWArray ConfigsList;
|
||||
extern CHAR16* DsdtsList[20];
|
||||
extern UINTN DsdtsNum;
|
||||
extern UINTN ConfigsNum;
|
||||
//extern INTN ScrollButtonsHeight;
|
||||
//extern INTN ScrollBarDecorationsHeight;
|
||||
//extern INTN ScrollScrollDecorationsHeight;
|
||||
|
@ -212,7 +212,11 @@ public:
|
||||
template<typename XStringClass1, enable_if(is___String(XStringClass1))>
|
||||
void insertAtPos(const XStringClass1 &aString, size_t pos) { array.InsertRef(new remove_const(XStringClass1)(aString), pos, true); }
|
||||
|
||||
template<typename CharType, enable_if(is_char(CharType))>
|
||||
void AddReference(CharType* newElement, bool FreeIt) { array.AddReference(new XStringClass_(newElement), FreeIt); }
|
||||
|
||||
void AddReference(XStringClass* newElement, bool FreeIt) { array.AddReference(newElement, FreeIt); }
|
||||
|
||||
void insertReferenceAtPos(XStringClass* newElement, size_t pos, bool FreeIt) { array.InsertRef(newElement, pos, FreeIt); }
|
||||
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
|
@ -134,8 +134,6 @@ extern void HelpRefit(void);
|
||||
extern void AboutRefit(void);
|
||||
//extern BOOLEAN BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize, LOADER_ENTRY *Entry);
|
||||
|
||||
extern UINTN ConfigsNum;
|
||||
extern CHAR16 *ConfigsList[];
|
||||
extern UINTN DsdtsNum;
|
||||
extern CHAR16 *DsdtsList[];
|
||||
extern EFI_AUDIO_IO_PROTOCOL *AudioIo;
|
||||
@ -792,12 +790,7 @@ void LOADER_ENTRY::StartLoader()
|
||||
}
|
||||
|
||||
//Free memory
|
||||
for (size_t i = 0; i < ConfigsNum; i++) {
|
||||
if (ConfigsList[i]) {
|
||||
FreePool(ConfigsList[i]);
|
||||
ConfigsList[i] = NULL;
|
||||
}
|
||||
}
|
||||
ConfigsList.setEmpty();
|
||||
for (size_t i = 0; i < DsdtsNum; i++) {
|
||||
if (DsdtsList[i]) {
|
||||
FreePool(DsdtsList[i]);
|
||||
@ -2464,9 +2457,8 @@ GetListOfConfigs()
|
||||
{
|
||||
REFIT_DIR_ITER DirIter;
|
||||
EFI_FILE_INFO *DirEntry;
|
||||
INTN NameLen;
|
||||
|
||||
ConfigsNum = 0;
|
||||
ConfigsList.setEmpty();
|
||||
OldChosenConfig = 0;
|
||||
|
||||
DirIterOpen(&selfOem.getConfigDir(), NULL, &DirIter);
|
||||
@ -2476,12 +2468,15 @@ GetListOfConfigs()
|
||||
continue;
|
||||
}
|
||||
if (StriCmp(DirEntry->FileName, L"config.plist") == 0) {
|
||||
OldChosenConfig = ConfigsNum;
|
||||
OldChosenConfig = ConfigsList.size(); // DirEntry->FileName is not yet inserted into ConfigsList. So its index will be ConfigsList.size()
|
||||
}
|
||||
NameLen = StrLen(DirEntry->FileName) - 6; //without ".plist"
|
||||
ConfigsList[ConfigsNum] = (CHAR16*)AllocateCopyPool(NameLen * sizeof(CHAR16) + 2, DirEntry->FileName);
|
||||
ConfigsList[ConfigsNum++][NameLen] = L'\0';
|
||||
size_t NameLen = wcslen(DirEntry->FileName) - 6; //without ".plist"
|
||||
if ( NameLen <= MAX_INTN ) {
|
||||
ConfigsList.AddReference(SWPrintf("%.*ls", (int)NameLen, DirEntry->FileName).forgetDataWithoutFreeing(), true); // this avoid to realloctae and copy memory
|
||||
DBG("- %ls\n", DirEntry->FileName);
|
||||
}else{
|
||||
DBG("- bug!, NameLen > MAX_INTN");
|
||||
}
|
||||
}
|
||||
DirIterClose(&DirIter);
|
||||
}
|
||||
|
@ -2543,9 +2543,9 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuConfigs()
|
||||
|
||||
SubScreen->AddMenuInfoLine_f("Select a config file:");
|
||||
|
||||
for (i = 0; i < ConfigsNum; i++) {
|
||||
for (i = 0; i < ConfigsList.size(); i++) {
|
||||
InputBootArgs = new REFIT_MENU_SWITCH;
|
||||
InputBootArgs->Title.takeValueFrom(ConfigsList[i]);
|
||||
InputBootArgs->Title = ConfigsList[i];
|
||||
// InputBootArgs->Tag = TAG_SWITCH_OLD;
|
||||
InputBootArgs->Row = i;
|
||||
InputBootArgs->Item = &InputItems[90];
|
||||
|
Loading…
Reference in New Issue
Block a user