Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions rEFIt_UEFI/PlatformEFI/cpp_util/operatorNewDelete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ void operator delete ( void* ptr ) noexcept
FreePool(ptr);
}

void operator delete[](void* ptr) noexcept
{
FreePool(ptr);
}

#ifdef _MSC_VER
void _cdecl operator delete (void * ptr, unsigned __int64 count)
#else
Expand Down
9 changes: 7 additions & 2 deletions rEFIt_UEFI/PlatformPOSIX+EFI/cpp_util/operatorNewDelete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ void operator delete ( void* ptr ) noexcept
{
// ++operator_delete_count1;
// MemLogf(false, 0, "operator delete(%llx) %lld\n", uintptr_t(ptr), operator_delete_count1);
return FreePool(ptr);
FreePool(ptr);
}

void operator delete[](void* ptr) noexcept
{
FreePool(ptr);
}

#ifdef _MSC_VER
Expand All @@ -59,7 +64,7 @@ void operator delete (void * ptr, UINTN count)
{
// ++operator_delete_count2;
// MemLogf(false, 0, "operator delete(%llx, %lld) %lld\n", uintptr_t(ptr), count, operator_delete_count2);
return FreePool(ptr);
FreePool(ptr);
}


Expand Down
9 changes: 7 additions & 2 deletions rEFIt_UEFI/PlatformPOSIX/cpp_util/operatorNewDelete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ void operator delete ( void* ptr ) noexcept
{
// ++operator_delete_count1;
// MemLogf(false, 0, "operator delete(%llx) %lld\n", uintptr_t(ptr), operator_delete_count1);
return FreePool(ptr);
FreePool(ptr);
}

void operator delete[](void* ptr) noexcept
{
FreePool(ptr);
}

#ifdef _MSC_VER
Expand All @@ -59,7 +64,7 @@ void operator delete (void * ptr, UINTN count)
{
// ++operator_delete_count2;
// MemLogf(false, 0, "operator delete(%llx, %lld) %lld\n", uintptr_t(ptr), count, operator_delete_count2);
return FreePool(ptr);
FreePool(ptr);
}


Expand Down
20 changes: 12 additions & 8 deletions rEFIt_UEFI/cpp_foundation/XStringAbstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,9 @@ class __String {
}

ThisXStringClass subString(size_t pos, size_t count) const {
// if ( pos > length() ) return ThisXStringClass();
// if ( count > length()-pos ) count = length()-pos;
size_t len = length();
if (pos >= len || count == 0) return ThisXStringClass();
if (count > len - pos) count = len - pos;

ThisXStringClass ret;

Expand Down Expand Up @@ -1017,7 +1018,7 @@ class XStringAbstract : public __String<T, ThisXStringClass, ThisLStringClass> {
~XStringAbstract() {
// DBG_XSTRING("Destructor :%ls\n", data());
if (m_allocatedSize > 0)
free((void *)super::__m_data);
delete[] super::__m_data;
}

#ifdef XSTRING_CACHING_OF_SIZE
Expand Down Expand Up @@ -1085,10 +1086,13 @@ class XStringAbstract : public __String<T, ThisXStringClass, ThisLStringClass> {
#endif
/* Copy Assign */
XStringAbstract &operator=(const XStringAbstract &S) {
if (this == &S) {
return *this;
}
if (S.data() && S.m_allocatedSize == 0) {
// S points to a litteral
if (m_allocatedSize > 0) {
delete super::__m_data;
delete[] super::__m_data;
m_allocatedSize = 0;
}
super::__m_data =
Expand All @@ -1106,7 +1110,7 @@ class XStringAbstract : public __String<T, ThisXStringClass, ThisLStringClass> {
/* Copy Assign */
XStringAbstract &operator=(const ls_t &S) {
if (m_allocatedSize > 0) {
delete super::__m_data;
delete[] super::__m_data;
m_allocatedSize = 0;
}
super::__m_data = (T *)S.data(); // because it's a litteral, we don't copy.
Expand Down Expand Up @@ -1631,7 +1635,7 @@ class XStringAbstract : public __String<T, ThisXStringClass, ThisLStringClass> {
/* size is in number of technical chars, NOT in bytes */
ThisXStringClass &stealValueFrom(T *S, size_t allocatedSize) {
if (m_allocatedSize > 0)
delete super::__m_data;
delete[] super::__m_data;
super::__m_data = S;
#ifdef XSTRING_CACHING_OF_SIZE
super::__m_size = utf_size_of_utf_string(super::__m_data, super::__m_data);
Expand All @@ -1644,7 +1648,7 @@ class XStringAbstract : public __String<T, ThisXStringClass, ThisLStringClass> {
// a future realloc may fail as EDK want the old size.
ThisXStringClass &stealValueFrom(T *S) {
if (m_allocatedSize > 0)
delete super::__m_data;
delete[] super::__m_data;
super::__m_data = S;
#ifdef XSTRING_CACHING_OF_SIZE
super::__m_size = utf_size_of_utf_string(super::__m_data, super::__m_data);
Expand All @@ -1657,7 +1661,7 @@ class XStringAbstract : public __String<T, ThisXStringClass, ThisLStringClass> {

ThisXStringClass &stealValueFrom(ThisXStringClass *S) {
if (m_allocatedSize > 0)
delete super::__m_data;
delete[] super::__m_data;
#ifdef XSTRING_CACHING_OF_SIZE
super::__m_size = S->size();
#endif
Expand Down
2 changes: 0 additions & 2 deletions rEFIt_UEFI/entry_scan/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,6 @@ void LOADER_ENTRY::AddDefaultMenu() {
UINT64 VolumeSize;
EFI_GUID Guid;
XBool KernelIs64BitOnly;
XStringW OldOSName{OSName};

constexpr LString8 quietLitteral = "quiet"_XS8;
constexpr LString8 splashLitteral = "splash"_XS8;
Expand Down Expand Up @@ -1628,7 +1627,6 @@ void LOADER_ENTRY::AddDefaultMenu() {
SubEntry->Title.SWPrintf("Run %ls", FileName.wc_str());
SubScreen->AddMenuEntry(SubEntry, true);
}
OSName = OldOSName;
}

LOADER_ENTRY *AddLoaderEntry(IN CONST XStringW &LoaderPath,
Expand Down
6 changes: 3 additions & 3 deletions rEFIt_UEFI/libeg/XTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,17 +867,17 @@ const XIcon& XTheme::LoadOSIcon(const XString8& Full)
DBG(" first=%s\n", First.c_str());
if (!ReturnIcon->isEmpty()) return *ReturnIcon;
//else search second name
Second = "os_"_XS8 + Full.subString(Comma + 1, Size - Comma - 1);
Second = "os_"_XS8 + Full.subString(Comma + 1, MAX_XSIZE);
//moreover names can be triple L"chrome,grub,linux"
UINTN SecondComma = Second.indexOf(',');
if (Comma == MAX_XSIZE) {
if (SecondComma == MAX_XSIZE) {
ReturnIcon = &GetIcon(Second);
if (!ReturnIcon->isEmpty()) return *ReturnIcon;
} else {
First = Second.subString(0, SecondComma);
ReturnIcon = &GetIcon(First);
if (!ReturnIcon->isEmpty()) return *ReturnIcon;
Third = "os_"_XS8 + Second.subString(SecondComma + 1, Size - SecondComma - 1);
Third = "os_"_XS8 + Second.subString(SecondComma + 1, MAX_XSIZE);
ReturnIcon = &GetIcon(Third);
if (!ReturnIcon->isEmpty()) return *ReturnIcon;
}
Expand Down
8 changes: 7 additions & 1 deletion rEFIt_UEFI/refit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1686,8 +1686,14 @@ void LOADER_ENTRY::StartLoader()
(UINT8 *)SysRoot;

size_t i1 = forceKext.rindexOf("\\") + 1;
if (i1 == MAX_XSIZE) i1 = 0;
size_t i2 = forceKext.rindexOf(".");
XStringW identifier = forceKext.subString(i1, i2 - i1);
XStringW identifier;
if (i2 != MAX_XSIZE && i2 > i1) {
identifier = forceKext.subString(i1, i2 - i1);
} else {
identifier = forceKext.subString(i1, MAX_XSIZE);
}
OC_STRING_ASSIGN(
mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->Identifier,
S8Printf("%ls", identifier.wc_str()).c_str());
Expand Down
Loading