| OLD | NEW |
| 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 #include "quick_sort.h" | 5 #include "quick_sort.h" |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include "utility.h" | 7 #include "utility.h" |
| 8 | 8 |
| 9 /* Make sure we won't overflow the buffer. */ | 9 /* Make sure we won't overflow the buffer. */ |
| 10 #define SAFE_SIZE(size) \ | 10 #define SAFE_SIZE(size) \ |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 pivot = (left + right) / 2; | 50 pivot = (left + right) / 2; |
| 51 pivot = Partition(compare_function, elements, size, left, right, pivot); | 51 pivot = Partition(compare_function, elements, size, left, right, pivot); |
| 52 RecursiveQuickSort(elements, left, pivot - 1, size, compare_function); | 52 RecursiveQuickSort(elements, left, pivot - 1, size, compare_function); |
| 53 RecursiveQuickSort(elements, pivot + 1, right, size, compare_function); | 53 RecursiveQuickSort(elements, pivot + 1, right, size, compare_function); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void QuickSort(void *elements, int number_of_elements, int size, | 56 void QuickSort(void *elements, int number_of_elements, int size, |
| 57 int (*compare_function)(const void *a, const void *b)) { | 57 int (*compare_function)(const void *a, const void *b)) { |
| 58 RecursiveQuickSort(elements, 0, number_of_elements - 1, size, compare_function
); | 58 RecursiveQuickSort(elements, 0, number_of_elements - 1, size, compare_function
); |
| 59 } | 59 } |
| OLD | NEW |