Pointers and Tuning and Loops! Oh My! (opens in new tab)
Introduction While all code should be efficient, code for library-like components, especially involving loops, should be as efficient as possible since such code is often widely used. In my , I included the source code for a function to clean-up a dynamic array: void array_cleanup( array_t *array, array_free_fn_t free_fn ) { if ( array == NULL ) return; if ( free_fn != NULL ) { char *element = array->elements; for ( size_t i = 0; i len; ++i ) { (*free_fn)( element ); element += array...
Read the original article