This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
malloc, new with cross-compiler gcc 2.95.3 on ARM9
- From: "Peter Skvarka" <ps at softinengines dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Thu, 13 Sep 2007 11:01:00 +0200
- Subject: malloc, new with cross-compiler gcc 2.95.3 on ARM9
- Reply-to: <ps at softinengines dot com>
I 'd like to have malloc and new which returns NULL if lack of memory on
embedded system Linux kernel 2.4.19-rmk7.
I was successful to set this behavior with the newest compiler on "big"
Linux + gcc 4.1.2 and also on embedded Linux kernel 2.4.19-rmk7 on ARM9 +
cross-compiler gcc 3.4.3 by this way:
for malloc:
mlockall(MCL_FUTURE);
char* ptr = (char*)malloc(xxxxxx);
if(ptr == NULL) {
//handle out of memory, functional
}
for new operator:
mlockall(MCL_FUTURE);
char* ptr = (char*) new(std:nothrow) char[xxxxx];
if(ptr == NULL) {
//handle error - functional
}
Problem is that I am not able to set this behavior on
embedded kernel 2.4.19-rmk7 + older cross-compiler 2.95.3.
In this case system outputs to console:
Out of Memory: Killed process 99 (memorysample).
Terminated
Do you think that there exist some solution also for older cross-compiler
2.95.3 ?
Regards !
Peter