Re: statfs(), xforms, and linux

Dr. T.C. Zhao (zhao@bragg.phys.uwm.edu)
Fri, 25 Apr 1997 22:47:17 -0500

To subscribers of the xforms list from "Dr. T.C. Zhao" <zhao@bragg.phys.uwm.edu> :

from "Robert S. Mallozzi" <mallors@ips1.msfc.nasa.gov> :

>void util(void)
>{
struct statfs *buf;
>
> buf = (struct statfs *) malloc (sizeof(statfs));
> ^^^^^^^^^^^^^^
> if (buf == NULL) {
> printf("could not malloc\n");
> exit (1);
> }

nasty bug/typo of the month. You're allocating
sizeof(statfs) bytes, which probably is only
about 4 bytes (now, sizeof(struct statfs) is a
completely different matter). I almost always do
buf = malloc(*buf).

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/xforms-archive/