MCPcopy Create free account
hub / github.com/TASEmulators/fceux / UpdateRecentLuaArray

Function UpdateRecentLuaArray

src/drivers/win/window.cpp:832–889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

830}
831
832void UpdateRecentLuaArray(const char* addString, char** bufferArray, unsigned int arrayLen, HMENU menu, unsigned int menuItem, unsigned int baseId)
833{
834 // Try to find out if the filename is already in the recent files list.
835 for(unsigned int x = 0; x < arrayLen; x++)
836 {
837 if(bufferArray[x])
838 {
839 if(!strcmp(bufferArray[x], addString)) // Item is already in list.
840 {
841 // If the filename is in the file list don't add it again.
842 // Move it up in the list instead.
843
844 int y;
845 char *tmp;
846
847 // Save pointer.
848 tmp = bufferArray[x];
849
850 for(y = x; y; y--)
851 {
852 // Move items down.
853 bufferArray[y] = bufferArray[y - 1];
854 }
855
856 // Put item on top.
857 bufferArray[0] = tmp;
858
859 // Update the recent files menu
860 UpdateLuaRMenu(menu, bufferArray, menuItem, baseId);
861
862 return;
863 }
864 }
865 }
866
867 // The filename wasn't found in the list. That means we need to add it.
868
869 // If there's no space left in the recent files list, get rid of the last
870 // item in the list.
871 if(bufferArray[arrayLen - 1])
872 {
873 free(bufferArray[arrayLen - 1]);
874 }
875
876 // Move the other items down.
877 for(unsigned int x = arrayLen - 1; x; x--)
878 {
879 bufferArray[x] = bufferArray[x - 1];
880 }
881
882 // Add the new item.
883 bufferArray[0] = (char*)malloc(strlen(addString) + 1); //mbg merge 7/17/06 added cast
884 strcpy(bufferArray[0], addString);
885
886 // Update the recent files menu
887 UpdateLuaRMenu(menu, bufferArray, menuItem, baseId);
888
889}

Callers 1

AddRecentLuaFileFunction · 0.85

Calls 1

UpdateLuaRMenuFunction · 0.85

Tested by

no test coverage detected