summaryrefslogtreecommitdiff
path: root/src/tsort.c
Commit message (Collapse)AuthorAgeFilesLines
* tsort: remove assertionEdward Thomson2020-11-271-2/+0
|
* tsort: remove idempotent conditional assignmentPatrick Steinhardt2017-07-211-1/+0
| | | | | The conditional `run < minrun` can never be true directly after assigning `run = minrun`. Remove it to avoid confusion.
* git__*allocarray: safer realloc and mallocEdward Thomson2015-02-121-2/+1
| | | | | | | | Introduce git__reallocarray that checks the product of the number of elements and element size for overflow before allocation. Also introduce git__mallocarray that behaves like calloc, but without the `c`. (It does not zero memory, for those truly worried about every cycle.)
* allocations: test for overflow of requested sizeEdward Thomson2015-02-121-1/+4
| | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* Sorting function cleanup and MinGW fixRussell Belfer2013-03-111-4/+4
| | | | | | | Clean up some sorting function stuff including fixing qsort_r on MinGW, common function pointer type for comparison, and basic insertion sort implementation (which we, regrettably, fall back on for MinGW).
* Add payload "_r" versions of bsearch and tsortRussell Belfer2013-01-151-22/+38
| | | | | | | | | git__bsearch and git__tsort did not pass a payload through to the comparison function. This makes it impossible to implement sorted lists where the sort order depends on external data (e.g. building a secondary sort order for the entries in a tree). This commit adds git__bsearch_r and git__tsort_r versions that pass a third parameter to the cmp function of a user payload.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Fix warnings on 64-bit windows buildsRussell Belfer2012-04-171-13/+15
| | | | | This fixes all the warnings on win64 except those in deps, which come from the regex code.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* global: Properly use `git__` memory wrappersVicent Marti2011-10-281-2/+2
| | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* Tabify everythingVicent Marti2011-09-191-2/+2
| | | | | | There were quite a few places were spaces were being used instead of tabs. Try to catch them all. This should hopefully not break anything. Except for `git blame`. Oh well.
* Cleanup legal dataVicent Marti2011-09-191-0/+6
| | | | | | | | | | 1. The license header is technically not valid if it doesn't have a copyright signature. 2. The COPYING file has been updated with the different licenses used in the project. 3. The full GPLv2 header in each file annoys me.
* tsort.c: fix include of common.hschu2011-08-171-1/+2
| | | | Signed-off-by: schu <schu-github@schulog.org>
* tsort: Remove unused CLZ methodsVicent Marti2011-07-091-19/+0
|
* win32: replace usage of _MSV_VER with _MSC_VERnulltoken2011-07-091-1/+1
|
* tsort: remove unused but set variableschu2011-07-071-3/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* tsort: fix wrong header inclusionnulltoken2011-07-071-7/+1
|
* Fix MSVC compilation warningsnulltoken2011-07-071-4/+9
|
* vector: Timsort all of the thingsVicent Marti2011-07-071-0/+380
Drop the GLibc implementation of Merge Sort and replace it with Timsort. The algorithm has been tuned to work on arrays of pointers (void **), so there's no longer a need to abstract the byte-width of each element in the array. All the comparison callbacks now take pointers-to-elements, not pointers-to-pointers, so there's now one less level of dereferencing. E.g. int index_cmp(const void *a, const void *b) { - const git_index_entry *entry_a = *(const git_index_entry **)(a); + const git_index_entry *entry_a = (const git_index_entry *)(a); The result is up to a 40% speed-up when sorting vectors. Memory usage remains lineal. A new `bsearch` implementation has been added, whose callback also supplies pointer-to-elements, to uniform the Vector API again.