To solve your problem, replace this
end_address = start_address + (memory_size/sizeof(end_address));
with:
end_address = start_address + (memory_size/sizeof(*end_address));
Reason: end_address
itself is a pointer while *end_address
is actually the data type that the pointer points to. It would lead to a problem when sizeof(uint32_t) != sizeof(char*)
e.g. on 64-bit or 16-bit systems.
However as you're operating with memory addresses, I would suggest you to use pointers with type char*
so you could do direct arithmetic with it:
char *memory_size = 0x00001000;
uint32_t memory_size = 0x1000;
char *end_address = memory_size + memory_size;
/* then it's assured that end_address == 0x00002000 */