[docs] add documentation group (#556)

* add documentation group

* function parameter docs

* fix function parameter direction

* free dynamic memory
This commit is contained in:
Krishna Vedala 2020-07-04 13:59:21 -04:00 committed by GitHub
parent 246f3e3f0e
commit b693440d55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -6,6 +6,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
/**
* @addtogroup sorting Sorting algorithms
* @{
*/
/** Create easy access of elements from a 2D matrix stored in memory as a 1D /** Create easy access of elements from a 2D matrix stored in memory as a 1D
* array * array
*/ */
@ -13,7 +17,7 @@
/** /**
* Displays the array, passed to this method * Displays the array, passed to this method
* @param [in,out] arr array to display * @param [in] arr array to display
* @param [in] n number of elements in the array * @param [in] n number of elements in the array
*/ */
void display(const int *arr, int n) void display(const int *arr, int n)
@ -65,6 +69,7 @@ void bead_sort(int *a, size_t len)
} }
free(beads); free(beads);
} }
/** @} */
/** Main function */ /** Main function */
int main(int argc, const char *argv[]) int main(int argc, const char *argv[])

View File

@ -8,6 +8,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
/**
* @addtogroup sorting Sorting algorithms
* @{
*/
/** Helper function to print array values */ /** Helper function to print array values */
void show_data(int *arr, long len) void show_data(int *arr, long len)
{ {
@ -15,7 +19,10 @@ void show_data(int *arr, long len)
printf("\n"); printf("\n");
} }
/** Function to swap values of two integers */ /** Function to swap values of two integers
* @param [in,out] a reference to first variable
* @param [in,out] b reference to second variable
*/
inline void swap(int *a, int *b) inline void swap(int *a, int *b)
{ {
int tmp; int tmp;
@ -26,7 +33,10 @@ inline void swap(int *a, int *b)
} }
/** /**
* Shell sort algorithm.\n
* Optimized algorithm - takes half the time as other * Optimized algorithm - takes half the time as other
* @param [in,out] array array to sort
* @param [in] LEN length of the array
*/ */
void shell_sort(int *array, long LEN) void shell_sort(int *array, long LEN)
{ {
@ -50,6 +60,7 @@ void shell_sort(int *array, long LEN)
for (i = 0; i < LEN; i++) printf("%s\t", data[i]); for (i = 0; i < LEN; i++) printf("%s\t", data[i]);
#endif #endif
} }
/** @} */
/** Main function */ /** Main function */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -80,5 +91,6 @@ int main(int argc, char *argv[])
printf("Time spent sorting: %.4g s\n", (t2 - t1) / CLOCKS_PER_SEC); printf("Time spent sorting: %.4g s\n", (t2 - t1) / CLOCKS_PER_SEC);
free(array);
return 0; return 0;
} }