Porting to RISC OS
Stefan Bellon
sbellon at sbellon.de
Tue Sep 2 20:08:57 CEST 2003
Hi!
I've ported bogofilter to the rarely known operating system RISC OS.
Depending on which RISC OS compiler I use, I run into trouble with the
xmalloc/xcalloc functions.
At present, it may be possible that malloc(0) is called and afterwards
it's checked what happened. I think it may be safer to rewrite the code
to read as follows:
void *
xmalloc(size_t size){
void *ptr;
if (size == 0)
size = 1;
ptr = malloc(size);
if (ptr == NULL) {
xmem_error("xmalloc");
}
return ptr;
}
void *
xcalloc(size_t nmemb, size_t size){
void *ptr;
if (nmemb == 0)
nmemb = 1;
if (size == 0)
size = 1;
ptr = calloc(nmemb, size);
if (ptr == NULL) {
xmem_error("xcalloc");
}
return ptr;
}
In fact, I had to rewrite it this way in order to work-around what
seems to be a bug in our UnixLib when compiling with the Norcroft C
compiler. When using GCC it works with the present code as well.
Greetings,
Stefan.
--
Hard work has a future payoff. Laziness pays off now.
More information about the bogofilter-dev
mailing list