From: "Rafał Maj" Newsgroups: comp.os.msdos.djgpp Subject: problems with new Date: Sat, 19 Aug 2000 01:08:28 +0200 Organization: Academic Computer Center CYFRONET AGH Lines: 42 Message-ID: <8nkfqr$hhj$2@info.cyf-kr.edu.pl> NNTP-Posting-Host: d-94-53-21.cyfronet.krakow.pl X-Trace: info.cyf-kr.edu.pl 966640283 17971 149.156.1.181 (18 Aug 2000 23:11:23 GMT) X-Complaints-To: news AT cyf-kr DOT edu DOT pl NNTP-Posting-Date: 18 Aug 2000 23:11:23 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I have a problem when I'm using new instead of malloc() : #1 void* ptr = malloc(100*1024*1024); That works fine, when ther isn't enought free memory, malloc() just returns NULL; #2 char *ptr = new[100*1024*1024]; OR, what I realy need : MyClass *ptr = new MyClass( var1, var2); If ther isn't free memory, that cause program to crash with : Call frame traceback: in function __djgpp_traceback_exit+48 in function raise+94 in function abort+27 in function __default_terminate+11 in function __terminate+13 in function throw_helper+535 in function __throw+110 in function __builtin_vec_new+26 c.cc(9) in function main in function __crt1_startup+174 =============================== How can I check, if next call to new() will cause crash, or will work correctly ? Or better, can I force new to return NULL when ther isn't free memory, like malloc is doing ? =============================== Or - can I write this expresion : MyClass *ptr = new MyClass( var1, var2); Using only malloc() ? I cann't check amount of free memory befor calling new (for example by _go32_remaining_virtual_memory()) because this function doesn't always return correct value. Rafal