Linked by Thom Holwerda on Wed 3rd Jan 2007 17:51 UTC, submitted by netpython
Privacy, Security, Encryption A US computer scientist and a Microsoft researcher have devised a program that drastically reduces application crashes and can prevent some types attack by altering the way applications use memory. The program, called DieHard, officially launched over the holidays, following development that was funded by large grants from Microsoft, Intel and the US' National Science Foundation.
Permalink for comment 198513
To read all comments associated with this story, please click here.
Allocate More Memory
by Yamin on Thu 4th Jan 2007 20:31 UTC
Yamin
Member since:
2006-01-10

Seems like plenty of folks seem to think you shouldn't allocate more memory than needed.

I am personally tired of seeing code like:
char name[7];
strcpy(name, "bob rob");

Especially if its on the stack. Why would you ever allocate exactly 7 chars? Is this case, its a bug. But even if it weren't, why not just allocate a reasonable large buffer. char name[64] or even 128.

Programmers micromanaging memory is a huge problem. Yes, for large arrays/collections of data, you should optimize it, but in general...allocate more. For arrays, allocate 1 or 2 more than your predetermined size.

I'd be nervous using a bridge that would only hold exactly my weight. People using arrayd should feel the same way ;)

Reply Score: 1