Thanks Ben, I appreciate the feed back.
Here's another thought, I know PalmOS does not support 'calloc' but then why
is it included as a function in 'cstdlib' and all these include files are
listed under the MSL directory of CodeWarrior. It would seem to me that they
are indicating that if you do an #include that the function should then be
prototyped. Am I missing something here?
Carl
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Ben
Combee
Sent: Wednesday, February 21, 2001 6:31 PM
To: Palm Developer Forum
Subject: Re: Using ansi c (calloc)
"Carl Smith" <[EMAIL PROTECTED]> wrote in message news:40564@palm-dev-forum...
>
> I have an app with numerous calls to calloc. I've included the file
#include
> <stdlib.h> which directs to the cstdlib file which in turn holds the
> prototype for calloc. Now if I don't include the
> #include <stdlib.h> I get compile errors as "Function has no prototype"
yet
> when I do include the stdlib.h file I get a link error of, "'calloc'
> referenced from 'myfunction' is undefined.
>
> Does any body have any suggestions as to what the problem might be? Could
my
> project be hitting the 64k barrier? Plus how does one tell when they are
at
> or above the 64k when the project will not compile?
You are assuming that calloc() is a supported function on PalmOS. It is
not.
Here is a quick inline version that should work similar to the ANSI C
function calloc(), and will also show you how memory is allocated on PalmOS.
inline void *calloc(UInt16 num, UInt16 size)
{
void *memory = MemPtrNew(num * size);
if (memory)
{
MemSet(memory, num * size, 0);
}
return memory;
}
and this should match with
inline void free(void *memory)
{
if (memory)
{
MemPtrFree(memory);
}
}
since your code does deallocate memory, I'd assume.
--
Ben Combee
Veriprise Wireless <http://www.veriprise.com>
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/