Got the bubble sort tests somewhat compiling (needs two consecutive invokations to compile), need to fix implementation bugs in there still.
This commit is contained in:
parent
06c58d8995
commit
233b303bff
|
@ -2,6 +2,7 @@
|
|||
/* Include guards + include statements. */
|
||||
#ifndef BUBBLE_SORT_C
|
||||
#define BUBBLE_SORT_C
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "bubble_sort.h"
|
||||
#include "../utils/swap_void.h"
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/* This header defines the function for bubble sort. */
|
||||
#ifndef BUBBLE_SORT_H
|
||||
#define BUBBLE_SORT_H
|
||||
/* Include statements. */
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Function definitions. */
|
||||
void* bubble_sort(void* array, int (*comparison_function)(const void*, const void*), const int length, size_t size);
|
||||
|
|
|
@ -8,7 +8,7 @@ bst_tests.o: bst_tests.c
|
|||
gcc -g -c bst_tests.c
|
||||
|
||||
bubble_sort_tests.out: swap_void.o array_print.o bubble_sort_tests.o
|
||||
gcc -g -fsanitize=address -fsanitize=leak -fsanitize=undefined swap_void.o array_print.o bubble_sort_tests.o -o bubble_sort_tests.out -lm
|
||||
gcc -g -fsanitize=address -fsanitize=leak -fsanitize=undefined swap_void.o array_print.o bubble_sort_tests.o -o bubble_sort_tests.out
|
||||
|
||||
bubble_sort_tests.o: bubble_sort_tests.c
|
||||
gcc -g -I ../utils -D DEBUG -c bubble_sort_tests.c
|
||||
|
@ -18,7 +18,7 @@ double_linked_list_tests.out: double_linked_list_tests.c
|
|||
|
||||
quick_sort_tests.out: array_print.o quick_sort_tests.o
|
||||
#gcc -g -fsanitize=address -fsanitize=leak -fsanitize=undefined quick_sort_tests.c -o quick_sort_tests.out
|
||||
gcc -g -fsanitize=address -fsanitize=leak -fsanitize=undefined array_print.o quick_sort_tests.o -o quick_sort_tests.out -lm
|
||||
gcc -g -fsanitize=address -fsanitize=leak -fsanitize=undefined array_print.o quick_sort_tests.o -o quick_sort_tests.out
|
||||
|
||||
quick_sort_tests.o: quick_sort_tests.c
|
||||
gcc -g -D DEBUG -c quick_sort_tests.c
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* Temp should be an allocated buffer, used to do the swap. */
|
||||
/* Size should be > 0. */
|
||||
/* Expect undefined behavior if conditions aren't met. */
|
||||
static inline void swap_void_ptr(void *first, void *second, void *temp, size_t size) {
|
||||
extern inline void swap_void_ptr(void *first, void *second, void *temp, size_t size) {
|
||||
/* Swap. */
|
||||
memcpy(temp, first, size);
|
||||
memcpy(first, second, size);
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
#include <string.h>
|
||||
|
||||
/* This function is used to swap void* objects. */
|
||||
static inline void swap_void_ptr(void *first, void *second, void *temp, size_t size);
|
||||
extern inline void swap_void_ptr(void *first, void *second, void *temp, size_t size);
|
||||
|
||||
#endif //SWAP_VOID_H
|
||||
|
|
Loading…
Reference in New Issue