I’m running into this (short) code and I’m not sure what it exactly does;
int amount = 5
int totalAllocatedMemory = 0;
totalAllocatedMemory += amount, malloc(amount);
It seems that ‘malloc’ has no effect here!
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It does have an effect, in that it allocates memory. However, the code does look bizarre and the memory does get leaked.
In case you’re wondering about the syntax and exact semantics, see How does the Comma Operator work