Alex.
Retired
- Joined
- Aug 24, 2005
- Messages
- 4,616
When I have something like char* test = malloc(1000), I call free(test) at the end of the program. However, what if I have:
After I'm done with everything, should I call free(datIndex)? or free(dataIndex[n])? My gut says I shouldn't do either, but I'd hate to have memory leaks :-\
Finally, what about char* text = "Hello world" - should I call free(text)? Again I myself think I shouldn't, because I didn't dynamically allocate any memory, but I'm having doubts. All C books I have refer to pointers either by address or by malloc(), so I'm left with this bit of confusion.
Thanks
- Alex
Code:
unsigned char data1[] = {blah blah blah};
unsigned char data2[] = {blah blah blah blah};
unsigned char data3[] = {blah bla};
unsigned char* dataIndex[] = {data1, data2, data3};
Finally, what about char* text = "Hello world" - should I call free(text)? Again I myself think I shouldn't, because I didn't dynamically allocate any memory, but I'm having doubts. All C books I have refer to pointers either by address or by malloc(), so I'm left with this bit of confusion.
Thanks
- Alex