Mail Archives: djgpp/1997/02/23/20:33:17
Bruce Merry <bmerry AT cssa DOT org DOT za> wrote:
>I've got an annoying problem. If I remember correctly (I've actually
>done not much C/C++, I'm a Pascal man) 'new' should return a NULL
>pointer if there is insufficient memory. I'm using DJGPP mostly for DPMI
>so that I can get loads of memory, but if I ask for too much my program
>just dies and says: Virtual memory exceeded in `new'. I want to be able
>to catch this properly. I'm prepared to overload the new operator if I
>have to, but I don't really want to.
Don't have an exacty answer for you, but Borlands compiler let you set
a callback function that would get called whenever new failed. The
function was called set_new_handler(<whatever>) I think. If new fails
it should still return zero, so you could set_new_handler to a dummy
function (or there is probably a better solution) and just test for a
zero...
- Calvin -
- Raw text -