This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

malloc, new with cross-compiler gcc 2.95.3 on ARM9


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]