#174162 - JackUzi - Fri May 21, 2010 4:20 am
I'm now working on the presumption that a memory alignment problem is causing my program to hang (although I'm not really sure it seems logical given it only hangs on ARM).
From what I've read the basic idea to make sure that each chunk of RAM falls on a 32bit/4 char boundary. Is that right?
Anyway, in my code I have been changing all char arrays and char mallocs to use a multiple of four. What I'm now worried about are all those string literals. For example:
I'm no C expert, but it is my understanding that the literal TESTING will be allocated on the fly resulting in a five char chunk of RAM (with the terminating null). Does this mean that every time I use a string literal I have to do something like this: "TEST\0 " ie, 4 characters, null, two spaces, then the system added null to make a total of eight bytes?
Stuart
From what I've read the basic idea to make sure that each chunk of RAM falls on a 32bit/4 char boundary. Is that right?
Anyway, in my code I have been changing all char arrays and char mallocs to use a multiple of four. What I'm now worried about are all those string literals. For example:
Code: |
function(char *blah) { puts(blah); } function("TEST"); |
I'm no C expert, but it is my understanding that the literal TESTING will be allocated on the fly resulting in a five char chunk of RAM (with the terminating null). Does this mean that every time I use a string literal I have to do something like this: "TEST\0 " ie, 4 characters, null, two spaces, then the system added null to make a total of eight bytes?
Stuart