Changing the value returned by sizeof


I’m replacing a struct with another struct of a different size. A problem arises when the following line occurs in the source code:

MyStruct *a = malloc(sizeof(a));

The ‘sizeof(a)’ is turned into a constant in the LLVM IR, resulting in the wrong amount of memory being allocated for the struct. Is there any way to find all the constants that have arisen from sizeof?

Thanks, Peter

a is a pointer.The size of a pointer always equals the size of an int,doesn’t it?

在 2014-4-9 下午4:32,“Peter Conn” <>写道:

Ah, sorry, I made a typo, I’d meant to write:

MyStruct *a = malloc(sizeof(MyStruct));