From c69c5c905b956b3ce3b4b6b12caab68e21060958 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 18 Nov 2012 21:33:20 +0000 Subject: [PATCH] Eolite 1.43: fixed largest memory leak, optimizations git-svn-id: svn://kolibrios.org@3057 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/fs/Eolite/trunk/Eolite.c-- | 31 +++++++------- .../fs/Eolite/trunk/include/about_dialog.h | 2 +- programs/fs/Eolite/trunk/lib/file_system.h | 41 +++++++++++-------- programs/fs/Eolite/trunk/txt/History.txt | 7 ++-- 4 files changed, 43 insertions(+), 38 deletions(-) diff --git a/programs/fs/Eolite/trunk/Eolite.c-- b/programs/fs/Eolite/trunk/Eolite.c-- index 641aec981a..6027335e5d 100644 --- a/programs/fs/Eolite/trunk/Eolite.c-- +++ b/programs/fs/Eolite/trunk/Eolite.c-- @@ -20,7 +20,7 @@ int BUTTON_HEIGHT=18; #define ONLY_OPEN 2 //переменные -#define title "Eolite File Manager v1.41" +#define title "Eolite File Manager v1.43" dword selection_col = 0x94AECE; dword lpanel_col = 0x00699C; @@ -383,10 +383,10 @@ void main() rename_active=1; break; case 052: //Нажата F3 - IF (isdir==false) RunProgram("/sys/tinypad", #file_path); + IF (!isdir) RunProgram("/sys/tinypad", #file_path); break; case 053: //Нажата F4 - IF (isdir==false) RunProgram("/sys/develop/heed", #file_path); + IF (!isdir) RunProgram("/sys/develop/heed", #file_path); break; case 054: //F5 Open_Dir(#path,1); @@ -398,16 +398,14 @@ void main() for (i=curbtn+za_kadrom+1; i='A')&&(AL<='Z')DSBYTE[#temp]=AL|0x20; - IF (temp[0]==key) + IF (temp[0]==key) || (temp[0]==key-32) { FileList_ReDraw(i-curbtn-za_kadrom); break; } } } - BREAK; + break; case evReDraw: draw_window(); } @@ -583,12 +581,10 @@ void Open_Dir(dword temp_, redraw){ char path_[4096], somelen=strlen(temp_)-1; - //debug("reading directory"); - //debug(temp_); if (redraw<>ONLY_SHOW) { copystr(temp_, #path_); - if (somelen) path_[somelen]=0x00; + if (somelen) path_[somelen]=NULL; if (buf) free(buf); buf = malloc(32); @@ -656,7 +652,7 @@ inline Sorting() IF (sort_num==2) Sort_by_Type(k,count-1); IF (sort_num==3) Sort_by_Size(k,count-1); //если папка ".." не первая, ставим её туда - IF (k>0) && (strcmp(file_mas[0]*304+buf+72,"..")<>0) FOR(k=k-1; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) file_mas[k]>0) && (strcmp(file_mas[0]*304+buf+72,"..")<>0) FOR(k--; k>0; k--;) IF (!strcmp(file_mas[k]*304+buf+72,"..")) file_mas[k]>0) { Write_Error(del_file_rez); - IF (isdir==true) ShowMessage("Error. Folder isn't empty."); - IF (isdir==false) ShowMessage("Error. Filesystem read-only."); + IF ( isdir) ShowMessage("Error. Folder isn't empty."); + IF (!isdir) ShowMessage("Error. Filesystem read-only."); } } del_active=0; @@ -727,8 +723,8 @@ void Paste() { copystr(#copy_file,#file_path); Del_File(true); - copy_file=''; - cut_active=0; + copy_file=NULL; + cut_active=false; } SelectFile(#new_copy_path+strchr(#new_copy_path,'/')); } @@ -801,10 +797,11 @@ void SelectFile(dword that_file) void Dir_Up() { char cur_folder[4096]; - if (!strcmp(#path,"/")) return; + if (path[1]==NULL) return; i=strlen(#path)-1; path[i]=0x00; - do i--; while (path[i]<>'/'); copystr(#path+i+1,#cur_folder); + do i--; while (path[i]<>'/'); + copystr(#path+i+1,#cur_folder); path[i+1]=0x00; SelectFile(#cur_folder); } diff --git a/programs/fs/Eolite/trunk/include/about_dialog.h b/programs/fs/Eolite/trunk/include/about_dialog.h index f9736ac1c5..bd0565dd29 100644 --- a/programs/fs/Eolite/trunk/include/about_dialog.h +++ b/programs/fs/Eolite/trunk/include/about_dialog.h @@ -38,7 +38,7 @@ void about_dialog() DefineAndDrawWindow(600,150,181,256,0x34,0x10EFEBEF,"About Eolite"); DrawBar(0,0,172,50,0x8494C4); //голубое сзади PutPaletteImage(#logo,85,85,43,7,#logo_pal); - WriteText(46,100,0x90,0xBF40BF,"Eolite v1.41",0); + WriteText(46,100,0x90,0xBF40BF,"Eolite v1.43",0); $add ebx, 1<<16 $int 0x40 WriteText(55,120,0x80,0,"Developers:",0); diff --git a/programs/fs/Eolite/trunk/lib/file_system.h b/programs/fs/Eolite/trunk/lib/file_system.h index 54bb9409a2..61895c9b10 100644 --- a/programs/fs/Eolite/trunk/lib/file_system.h +++ b/programs/fs/Eolite/trunk/lib/file_system.h @@ -133,6 +133,25 @@ int DeleleFile(dword del_file_path) $int 0x40 } +/////////////////////////// +// Параметры файла // +/////////////////////////// +/*f70 getinfo_file_70; +BDVK getinfo_file_info; +:dword GetFileInfo(dword file_path) +{ + getinfo_file_70.func = 5; + getinfo_file_70.param1 = + getinfo_file_70.param2 = + getinfo_file_70.param3 = 0; + getinfo_file_70.param4 = #getinfo_file_info; + getinfo_file_70.rezerv = 0; + getinfo_file_70.name = file_path; + $mov eax,70 + $mov ebx,#getinfo_file_70.func + $int 0x40 +}*/ + /////////////////////////// // Скопировать файл // /////////////////////////// @@ -140,7 +159,7 @@ f70 CopyFile_f; inline fastcall int CopyFile(dword EBX,ECX) { BDVK CopyFile_atr; - dword s=EBX, d=ECX, cBufer=0; + dword s=EBX, d=ECX, cBufer=0, rezult; CopyFile_f.func = 5; CopyFile_f.param1 = 0; CopyFile_f.param2 = 0; @@ -155,23 +174,11 @@ inline fastcall int CopyFile(dword EBX,ECX) if (!EAX) { cBufer = malloc(2*CopyFile_atr.sizelo); - ReadFile(dword 0, CopyFile_atr.sizelo, cBufer, s); - - IF (!EAX) - { - CopyFile_f.func = 2; - CopyFile_f.param1 = 0; - CopyFile_f.param2 = 0; - CopyFile_f.param3 = CopyFile_atr.sizelo; - CopyFile_f.param4 = cBufer; - CopyFile_f.rezerv = 0; - CopyFile_f.name = d; - $mov eax, 70 - $mov ebx, #CopyFile_f - $int 0x40 - } + if (!ReadFile(0, CopyFile_atr.sizelo, cBufer, s)) + rezult = CreateFile(CopyFile_atr.sizelo, cBufer, d); + free(cBufer); } - return EAX; + return rezult; } diff --git a/programs/fs/Eolite/trunk/txt/History.txt b/programs/fs/Eolite/trunk/txt/History.txt index 7d81c37edf..b5261aa7d0 100644 --- a/programs/fs/Eolite/trunk/txt/History.txt +++ b/programs/fs/Eolite/trunk/txt/History.txt @@ -1,8 +1,9 @@ -16.11.12 -- v1.4 +16.11.12 -- v1.43 - при минимальном размере окна учитывается количество дисков в системе; - добавлен фон на левую панель; -- изменения в организации файлов; -- удаление виртуальных дисков типа /tmpX/1. +- удаление виртуальных дисков типа /tmpX/1; +- исправлена страшнейшая утечка памяти равная размеру копируемого файла; +- улучшения в организации файлов и кода. 15.11.12 -- v1.36 - устранена утечка памяти при сканировании устройств;