we all were wondering what is wrong, and eclipse(CDT) was the first target, but debugging in eclipse also worked fine, and now we decided to go manual line by line checking so few things are observed
- they wanted a 2D array for which they know that the column size is two and row size should be dynamically allocated
- Array of pointers were used
now its time for more digging, so i prefer to user -Wall option to clean and make my code perfect, there i noticed one warning, function returns reference to local pointer, voila got it... so changed the function a bit, instead of returning a pointer we passed a pointer to the function and worked on it, and the result SUCCESS.
it shouldn't have taken much time for me to find out, being an OS student, we always deal with functions(system calls) which take pointer as an argument instead of returning them, so there must be something wrong/bad in returning the reference to local pointer, the memory gets lost!!!. but why not in debugging, the only reason that came to my mind is when debugging the memory areas used by the program is locked till it is freed or the program ends.
Blogged with Flock
No comments:
Post a Comment