diff options
-rw-r--r-- | source/blender/blenlib/BLI_sort.h | 6 | ||||
-rw-r--r-- | source/blender/blenlib/intern/sort.c | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_sort.h b/source/blender/blenlib/BLI_sort.h index 9e533aac758..4df17d98a4b 100644 --- a/source/blender/blenlib/BLI_sort.h +++ b/source/blender/blenlib/BLI_sort.h @@ -36,6 +36,10 @@ /* Quick sort reentrant */ typedef int (*BLI_sort_cmp_t)(void *ctx, const void *a, const void *b); -void BLI_qsort_r(void *a, size_t n, size_t es, void *thunk, BLI_sort_cmp_t cmp); +void BLI_qsort_r(void *a, size_t n, size_t es, void *thunk, BLI_sort_cmp_t cmp) +#ifdef __GNUC__ +__attribute__((nonnull(1, 5))) +#endif +; #endif /* __BLI_SORT_H__ */ diff --git a/source/blender/blenlib/intern/sort.c b/source/blender/blenlib/intern/sort.c index fdfdf5f67ca..44110564948 100644 --- a/source/blender/blenlib/intern/sort.c +++ b/source/blender/blenlib/intern/sort.c @@ -81,6 +81,11 @@ BLI_INLINE char *med3(char *a, char *b, char *c, BLI_sort_cmp_t cmp, void *thunk :(CMP(thunk, b, c) > 0 ? b : (CMP(thunk, a, c) < 0 ? a : c )); } +/** + * Quick sort reentrant. + * + * \note Follows BSD arg order (incompatible with glibc). + */ void BLI_qsort_r(void *a, size_t n, size_t es, void *thunk, BLI_sort_cmp_t cmp) { char *pa, *pb, *pc, *pd, *pl, *pm, *pn; |