Our hand-rolled fallback sorting function `git__insertsort_r` does an in-place sort of the given array. As elements may not necessarily be pointers, it needs a way of swapping two values of arbitrary size, which is currently implemented by allocating a temporary buffer of the element's size. This is problematic, though, as the emulated `qsort` interface doesn't provide any return values and thus cannot signal an error if allocation of that temporary buffer has failed. Convert the function to swap via a temporary buffer allocated on the stack. Like this, it can `memcpy` contents of both elements in small batches without requiring a heap allocation. The buffer size has been chosen such that in most cases, a single iteration of copying will suffice. Most importantly, it can fully contain `git_oid` structures and pointers. Add a bunch of tests for the `git__qsort_r` interface to verify nothing breaks. Furthermore, this removes the declaration of `git__insertsort_r` and makes it static as it is not used anywhere else.
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| array.c | Loading commit data... | |
| bitvec.c | Loading commit data... | |
| buffer.c | Loading commit data... | |
| copy.c | Loading commit data... | |
| dirent.c | Loading commit data... | |
| encoding.c | Loading commit data... | |
| env.c | Loading commit data... | |
| errors.c | Loading commit data... | |
| features.c | Loading commit data... | |
| filebuf.c | Loading commit data... | |
| ftruncate.c | Loading commit data... | |
| futils.c | Loading commit data... | |
| hex.c | Loading commit data... | |
| iconv.c | Loading commit data... | |
| init.c | Loading commit data... | |
| link.c | Loading commit data... | |
| memmem.c | Loading commit data... | |
| mkdir.c | Loading commit data... | |
| oid.c | Loading commit data... | |
| oidmap.c | Loading commit data... | |
| opts.c | Loading commit data... | |
| path.c | Loading commit data... | |
| pool.c | Loading commit data... | |
| posix.c | Loading commit data... | |
| pqueue.c | Loading commit data... | |
| qsort.c | Loading commit data... | |
| rmdir.c | Loading commit data... | |
| sha1.c | Loading commit data... | |
| sortedcache.c | Loading commit data... | |
| stat.c | Loading commit data... | |
| string.c | Loading commit data... | |
| strmap.c | Loading commit data... | |
| strtol.c | Loading commit data... | |
| structinit.c | Loading commit data... | |
| useragent.c | Loading commit data... | |
| vector.c | Loading commit data... | |
| wildmatch.c | Loading commit data... | |
| zstream.c | Loading commit data... |