I think your malloc is wrong. It should be board_type *board = malloc(sizeof(board_type)); /* instead of sizeof(square_type) Besides this I think your code is correct.
I think your malloc is wrong. It should be board_type *board = malloc(sizeof(board_type)); /* instead of sizeof(square_type) ...*/ Besides this I think your code is correct ...
Yea, been totally blind from starring at the code. Thanks – Patrick Feb 13 '10 at 21:06.
Others have already pointed out the error, but here's a macro that will help catch those errors: #define NEW(type) (type *)malloc(sizeof(type)) You would then use it like this: // Correct usage board_type *board = NEW(board_type); What nice about this is that if you make a mistake like you did, you should get a compiler warning about mismatched pointers due to the cast inside the macro: // Incorrect usage, a decent compiler will issue a warning board_type *board = NEW(square_type).
First, you are allocating the wrong size here: board_type *board = malloc(sizeof(square_type)); It needs to be board_type *board = malloc(sizeof(board_type)); You probably didn't saw this problem, but I suspect you are writing to unallocated memory. (Potential memory exception). You don't need to free the inner array, because it is a fixed size array, and when you allocate a board_type, it will be ready with the entire array.
Fix the malloc, it will solve the free.
Yea, been totally blind from starring at the code. Thanks – Patrick Feb 13 '10 at 21:07.
Another nitpick, nothing to do with your memory problem: you probably don't need an extra flag to mark free squares if you already distinguish between the three possible pieces CROSS / CIRCLE / NONE...
You probably didn't saw this problem, but I suspect you are writing to unallocated memory. (Potential memory exception). You don't need to free the inner array, because it is a fixed size array, and when you allocate a board_type, it will be ready with the entire array.
Fix the malloc, it will solve the free.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.