malloc bug?

mkwired:
Can someone explain why availableMemory() always returns the same value regardless of the size of buffer?

I'd expect that to return the size of the first successfully allocated buffer. What makes you think it doesn't?

wanderson:

pekkaa:
Perhaps the compiler optimizes buffer off because you don't use it.

From the attached disassembly of the sketch, that appears to be what happened.

I don't often need to look at assembler, but I had a look at your listing because I was intrigued to see how the compiler could legitimately optimise out the malloc() calls. It doesn't look to me as if it would be a reasonable thing to do, and I couldn't see anything in the assembler to suggest that it had done. Did I misunderstand you?