Terminate the application

When the user exits the Falling Blocks application, glview_loop() invokes the finalize callback. We need to do some clean-up to free up resources before the app shuts down.
static void finalize(void *data) {
    app_t *app = (app_t*)data;
We need to free the memory that was allocated for the blocks. Because we used calloc() to allocate the memory, we should free it manually to make sure that we don't create a memory leak. The system should deallocate this memory anyways, but it's a good practice to do it explicitly when we're done using it.

That's it! Let the blocks fall where they may! You can try altering the application to use the z-axis and give the falling blocks a 3-D effect or just change the color and size of the blocks.

Last modified: 2014-05-14

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus