Coding mishaps

I finally tracked down the reason for a problem I’ve had for a while:

char *tempdata= (char*)malloc(sizeof(data_packet->datalen));

Should have been:

char *tempdata= (char*)malloc(data_packet->datalen);

Force of habit must have seen me putting the sizeof() inside the malloc() without thinking. The mistake of an amateur.


Posted by Stephen Strowes on Monday, March 14th, 2005. You can follow me on twitter.

Recent Posts

(full archive)

All content, including images, © Stephen D. Strowes, 2000–2016. Hosted by Digital Ocean.