Hi. If I have a little sub-routine such as:
void MyFunc(void)
{
struct locks *gottem;
memset(&gottem, 0, sizeof(gottem)); /* more clean code */
...
...
}
As I enter this sub-routine under debug, with the cursor at the memset call, debug shows for my 'gottem' structure + gottem, {...}, struct *, 4015c4 where "+" is the little plus sign in a box, {...} is the value of the variable, and 4015c4 is what I assume is the address of the structure.
Now I hit F11, the memset is executed and the debug window shows + gottem, NULL, struct *, and 00000000. If I look at memory location 4015c4 it has not changed.
What is debug trying to tell me????
Thanks.
You are defining 'gottem' as a pointer to a 'locks' structure.
Then, getting '&gottem, you perform a memset on the address of the address of the structure=the pointer itself.
Then memset set to 0 the pointer, that gives you gottem=0.
Maybe you would have write:
void MyFunc(void)
{
struct locks gottem; //Define a structure not a pointer to.....
memset(&gottem, 0, sizeof(gottem)); /* more clean code */
...
...
}
or
void MyFunc(void)
{
struct locks *gottem; //Define a pointer to structure
gottem=&MyPreviouslyDefinedStructure; //Assign it the address of a structure defined elsewhere
memset(gottem, 0, sizeof(gottem)); /* pass the gottem pointer that corrctly references a locks type structure */
...
...
}