From e4b55f0dfbbe71d501d70346380c80e74edabdc4 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Thu, 17 Nov 2016 21:23:36 +0000 Subject: [PATCH] WebView and draw_buf.h: show error notification if requested memory size is more than free RAM size git-svn-id: svn://kolibrios.org@6724 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/browser/WebView.c | 7 +++---- programs/cmm/lib/draw_buf.h | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 0795b9b1f0..8137797901 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -30,7 +30,7 @@ char homepage[] = FROM "html\\homepage.htm""\0"; #ifdef LANG_RUS -char version[]="Текстовый браузер 1.5"; +char version[]="Текстовый браузер 1.51"; ?define IMAGES_CACHE_CLEARED "Кэш картинок очищен" ?define T_LAST_SLIDE "Это последний слайд" char loading[] = "Загрузка страницы...
"; @@ -43,7 +43,7 @@ char rmb_menu[] = Очистить кэш картинок Менеджер загрузок"; #else -char version[]="Text-based Browser 1.5"; +char version[]="Text-based Browser 1.51"; ?define IMAGES_CACHE_CLEARED "Images cache cleared" ?define T_LAST_SLIDE "This slide is the last" char loading[] = "Loading...
"; @@ -263,8 +263,7 @@ void SetElementSizes() WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; WB1.list.visible = WB1.list.h - 5 / WB1.list.item_h; if (WB1.list.w!=WB1.DrawBuf.bufw) { - if (WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 2048 * WB1.list.item_h) == false) - die("Memory allocation error! Seems to be too little RAM."); + WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 2048 * WB1.list.item_h); ProcessEvent(REFRESH_BUTTON); } } diff --git a/programs/cmm/lib/draw_buf.h b/programs/cmm/lib/draw_buf.h index e216469661..3b182fb9ea 100644 --- a/programs/cmm/lib/draw_buf.h +++ b/programs/cmm/lib/draw_buf.h @@ -25,13 +25,29 @@ struct DrawBufer { bool DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh) { + dword alloc_size, free_ram_size; + char error_str[256]; if (!zoom) zoom = 1; bufx = i_bufx; bufy = i_bufy; bufw = i_bufw * zoom; bufh = i_bufh * zoom; free(buf_data); - buf_data = malloc(bufw * bufh * 4 + 8); + $mov eax, 18 + $mov ebx, 16 + $int 0x40 + free_ram_size = EAX * 1024; + alloc_size = bufw * bufh * 4 + 8; + if (alloc_size >= free_ram_size) { + sprintf(#error_str, +"'DrawBufer needs more memory than currenly available. +Application could be unstable. + +Requested size: %i Kb. +Free RAM: %i Kb' -E", alloc_size/1024, free_ram_size/1024); + notify(#error_str); + } + buf_data = malloc(alloc_size); //debugval("buf_data",buf_data); if (!buf_data) return false; ESDWORD[buf_data] = bufw;