
Genetic Algorithm Implementation 103
index is valid. You should also check whether the system has enough memory space
to be allocated to the array every time you are allocating memory space. You can use
the
assert() routine defined in ASSERT.H or write your own error checking.
If
assert() is used in your source code, it is recommended that you remove the
assert statements from the source code once your program has been debugged.
Listing 4.5 is an example of error checking for memory allocation.
Listing 4.5
An example of error checking for memory allocation.
/* allocate memory space for the array */
population = (int **)calloc(number_of_row, sizeof(int