mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-04 07:01:04 +01:00 
			
		
		
		
	Demo: Fixed malloc/free mismatch and leak when destructing demo console (if it has been used) (#536)
This commit is contained in:
		@@ -1890,14 +1890,14 @@ struct ExampleAppConsole
 | 
			
		||||
    ~ExampleAppConsole()
 | 
			
		||||
    {
 | 
			
		||||
        ClearLog();
 | 
			
		||||
        for (int i = 0; i < Items.Size; i++)
 | 
			
		||||
        for (int i = 0; i < History.Size; i++)
 | 
			
		||||
            free(History[i]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Portable helpers
 | 
			
		||||
    static int   Stricmp(const char* str1, const char* str2)         { int d; while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } return d; }
 | 
			
		||||
    static int   Strnicmp(const char* str1, const char* str2, int n) { int d = 0; while (n > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; n--; } return d; }
 | 
			
		||||
    static char* Strdup(const char *str)                             { size_t len = strlen(str) + 1; void* buff = ImGui::MemAlloc(len); return (char*)memcpy(buff, (const void*)str, len); }
 | 
			
		||||
    static char* Strdup(const char *str)                             { size_t len = strlen(str) + 1; void* buff = malloc(len); return (char*)memcpy(buff, (const void*)str, len); }
 | 
			
		||||
 | 
			
		||||
    void    ClearLog()
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user