| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | malloc and the resulting |
Hi Dominique,
You wrote to Tom Torfs:
DC> TT> You really should include , instead of
DC> TT> providing your own prototype for malloc().
DC>Actually, no..
Actually Yes...
Tom is correct.
DC> I have to include my own declaration because I am
DC>allocating memory for a character array.. When I comment it out,
DC>I run out of memory very quickly... the standard declaration for
DC>malloc would be void malloc() or something... mine, char *malloc();
DC>is necessary for what I'm doing.
Then you cast the return from malloc(), the return type in the prototype
is void specifically so that you can convert it to whatever type you
actually require.
char *test;
...
if (NULL == (test = (char *)malloc (80)))
{
printf ("Unable to allocate memory\n"); /* Or whatever */
...
}
...
free (test);
George
* SLMR 2.1a * Computers eliminate spare time.
--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-717904) (2:440/4)SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 810 639/252 SEEN-BY: 670/218 @PATH: 440/4 255/1 251/25 396/1 633/260 635/506 728 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.