By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,327 Members | 2,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,327 IT Pros & Developers. It's quick & easy.

malloc and memset sgi

P: 2
Hello,
I've noticed recently that memset() is needed after malloc() to get an initialized memory zone xith sgi machines.
This didn't appenned with code compiled on sun machine
Is this normal ?
Sep 21 '06 #1
Share this Question
Share on Google+
2 Replies


100+
P: 144
I'm not sure I understand what you are asking. How are you using malloc and memset (code example and explanation of problem if you don't follow a malloc with a memset)? Is your concern that malloc isn't returning memory that has been zeroed out? If this is the case then you should keep in mind that it is not guarentteed that malloc clears the returned memory. Typical implementations don't. In this case yes you would want to use memset to zero out your newly allocated memory.
Sep 21 '06 #2

P: 2
I'm not sure I understand what you are asking. How are you using malloc and memset (code example and explanation of problem if you don't follow a malloc with a memset)? Is your concern that malloc isn't returning memory that has been zeroed out? If this is the case then you should keep in mind that it is not guarentteed that malloc clears the returned memory. Typical implementations don't. In this case yes you would want to use memset to zero out your newly allocated memory.
Indeed, my concern is that malloc isn't returning memory that has been zeroed out. Your advice is what I expected. I was just surprised of the differences between sun and sgi. I understand that it's far better to call memset after malloc to make sure the returned memory is zeroed out.
Thank's a lot
Sep 22 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.