diff --git a/source/channel/channels.cpp b/source/channel/channels.cpp index f98258e4..4f707c65 100644 --- a/source/channel/channels.cpp +++ b/source/channel/channels.cpp @@ -240,7 +240,7 @@ wchar_t * Channels::GetName(int index) return channels.at(index).name; } -int Channels::Count() +u32 Channels::Count() { return channels.size(); } diff --git a/source/channel/channels.h b/source/channel/channels.h index 08be6795..5e05fa40 100644 --- a/source/channel/channels.h +++ b/source/channel/channels.h @@ -48,36 +48,35 @@ typedef struct class Channels { - public: - Channels(); - ~Channels(); +public: + Channels(); + ~Channels(); - void Init(u32 channelType, string lang, bool reload = false); + void Init(u32 channelType, string lang, bool reload = false); - u32 Load(u64 title); - u8 GetRequestedIOS(u64 title); + u32 Load(u64 title); + u8 GetRequestedIOS(u64 title); - int Count(); - wchar_t *GetName(int index); - char *GetId(int index); - u64 GetTitle(int index); - Channel *GetChannel(int index); + u32 Count(); + wchar_t *GetName(int index); + char *GetId(int index); + u64 GetTitle(int index); + Channel *GetChannel(int index); - static Banner * GetBanner(u64 title, bool imetOnly = false); - private: - bool init; - u32 channelType; - string langCode; + static Banner * GetBanner(u64 title, bool imetOnly = false); +private: + bool init; + u32 channelType; + string langCode; - vector channels; - - static int GetLanguage(const char *lang); - u64* GetChannelList(u32* count); - static bool GetAppNameFromTmd(u64 title, char* app, bool dol = false, u32* bootcontent = NULL); - static bool GetChannelNameFromApp(u64 title, wchar_t* name, int language); + vector channels; - void Search(u32 channelType, string lang); - + static int GetLanguage(const char *lang); + u64* GetChannelList(u32* count); + static bool GetAppNameFromTmd(u64 title, char* app, bool dol = false, u32* bootcontent = NULL); + static bool GetChannelNameFromApp(u64 title, wchar_t* name, int language); + + void Search(u32 channelType, string lang); }; extern Channels ChannelHandle; diff --git a/source/list/ListGenerator.cpp b/source/list/ListGenerator.cpp index 0c2ccf58..cece3ecf 100644 --- a/source/list/ListGenerator.cpp +++ b/source/list/ListGenerator.cpp @@ -116,15 +116,15 @@ static void Create_Wii_EXT_List(char *FullPath) } } +static const char *FST_APPEND = "sys/boot.bin"; +static const u8 FST_APPEND_SIZE = strlen(FST_APPEND); static void Create_GC_List(char *FullPath) { - static const char *FST_APPEND = "sys/boot.bin"; - FILE *fp = fopen(FullPath, "rb"); if(!fp && strstr(FullPath, "/root") != NULL) //fst folder { *(strstr(FullPath, "/root") + 1) = '\0'; - if(strlen(FullPath) + strlen(FST_APPEND) < 255) strcat(FullPath, FST_APPEND); + if(strlen(FullPath) + FST_APPEND_SIZE < 256) strcat(FullPath, FST_APPEND); fp = fopen(FullPath, "rb"); } if(fp) @@ -176,11 +176,12 @@ static void Create_Homebrew_List(char *FullPath) m_gameList.push_back(ListElement); } +static Channel *chan = NULL; static void Create_Channel_List() { - for(int i = 0; i < ChannelHandle.Count(); i++) + for(u32 i = 0; i < ChannelHandle.Count(); i++) { - Channel *chan = ChannelHandle.GetChannel(i); + chan = ChannelHandle.GetChannel(i); if(chan->id == NULL) continue; // Skip invalid channels memset((void*)&ListElement, 0, sizeof(dir_discHdr)); @@ -272,14 +273,14 @@ void GetFiles(const char *Path, const vector& FileTypes, pdir = opendir(Path); if(pdir == NULL) return; - char *FullPathChar = (char*)MEM2_alloc(256); + char FullPathChar[256]; if(FullPathChar == NULL) return; + memset(FullPathChar, 0, 256); while((pent = readdir(pdir)) != NULL) { if(pent->d_name[0] == '.') continue; - memset(FullPathChar, 0, 256); strncpy(FullPathChar, fmt("%s/%s", Path, pent->d_name), 255); if(pent->d_type == DT_DIR) { @@ -308,6 +309,5 @@ void GetFiles(const char *Path, const vector& FileTypes, } } } - MEM2_free(FullPathChar); closedir(pdir); }