I would appreciate some suggestions on how to use <sapi/malloc.h>
properly. The comments therein are quite helpful, but not conclusive.
Consider the following code, for the inquiries that follow:
// begin code fragment
#include <sapi/malloc.h>
void *operator new(size_t n) throw()
{
S_apiMallocTypeFlags t = S_apiSetMallocType(S_API_MALLOC_INTERNAL);
void *p = S_apiMalloc(n);
S_apiSetMallocType(t);
return p;
}
void operator delete(void *p) throw()
{
if (p)
S_apiFree(p);
}
// end code fragment
First, is it safe to use SAPI this way? The documentation for S
discusses only the use of Calloc, Free, S_alloc, and other similar
functions.
Second, can S_apiMalloc ever return NULL? (Does S_apiMalloc handle
allocation errors?)
Finally, if there are related unaddressed issues, please feel free to
offer comments.
Jonathan Higa, higa@math.hawaii.edu, S+ user
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news