summaryrefslogtreecommitdiff
path: root/src/util.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #3288 from ethomson/getenvCarlos Martín Nieto2015-07-071-0/+5
|\ | | | | git__getenv: utf-8 aware env reader
| * git__getenv: utf-8 aware env readerEdward Thomson2015-07-021-0/+5
| | | | | | | | | | | | Introduce `git__getenv` which is a UTF-8 aware `getenv` everywhere. Make `cl_getenv` use this to keep consistent memory handling around return values (free everywhere, as opposed to only some platforms).
* | Include stacktrace summary in memory leak output.Jeff Hostetler2015-06-291-5/+8
|/
* git__tolower: a tolower() that isn't dumbEdward Thomson2015-05-291-0/+9
| | | | | | | | Some brain damaged tolower() implementations appear to want to take the locale into account, and this may require taking some insanely aggressive lock on the locale and slowing down what should be the most trivial of trivial calls for people who just want to downcase ASCII.
* Add MSVC CRTDBG memory leak reporting.Jeff Hostetler2015-04-151-0/+117
|
* Make our overflow check look more like gcc/clang'sEdward Thomson2015-02-131-10/+9
| | | | | | | | | Make our overflow checking look more like gcc and clang's, so that we can substitute it out with the compiler instrinsics on platforms that support it. This means dropping the ability to pass `NULL` as an out parameter. As a result, the macros also get updated to reflect this as well.
* Introduce git__add_sizet_overflow and friendsEdward Thomson2015-02-121-28/+0
| | | | | Add some helper functions to check for overflow in a type-specific manner.
* p_read: ensure requested len is ssize_tEdward Thomson2015-02-121-0/+7
| | | | | Ensure that the given length to `p_read` is of ssize_t and ensure that callers test the return as if it were an `ssize_t`.
* overflow checking: don't make callers set oomEdward Thomson2015-02-121-11/+4
| | | | | | Have the ALLOC_OVERFLOW testing macros also simply set_oom in the case where a computation would overflow, so that callers don't need to.
* git__*allocarray: safer realloc and mallocEdward Thomson2015-02-121-0/+22
| | | | | | | | 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-2/+13
| | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* Remove strlen() calls from loop conditionMaks Naumov2015-01-151-1/+1
| | | | Avoid str length recalculation every iteration
* Added AmigaOS-specific implementation of git__timer().Sebastian Bauer2014-12-281-0/+11
| | | | | | | The clock_gettime() function is normally not available under AmigaOS, hence another solution is required. We are using now GetUpTime() that is present in current versions of this operating system.
* don't treat 0x85 as whitespaceEdward Thomson2014-12-231-2/+2
| | | | | | A byte value of 0x85 is not whitespace, we were conflating that with U+0085 (UTF8: 0xc2 0x85). This caused us to incorrectly treat valid multibyte characters like U+88C5 (UTF8: 0xe8 0xa3 0x85) as whitespace.
* path: Use UTF8 iteration for HFS charsVicent Marti2014-12-161-0/+11
|
* checkout: disallow bad paths on win32Edward Thomson2014-12-161-0/+1
| | | | | | | | | | | | | | | Disallow: 1. paths with trailing dot 2. paths with trailing space 3. paths with trailing colon 4. paths that are 8.3 short names of .git folders ("GIT~1") 5. paths that are reserved path names (COM1, LPT1, etc). 6. paths with reserved DOS characters (colons, asterisks, etc) These paths would (without \\?\ syntax) be elided to other paths - for example, ".git." would be written as ".git". As a result, writing these paths literally (using \\?\ syntax) makes them hard to operate with from the shell, Windows Explorer or other tools. Disallow these.
* Fix typo in timer normalization constantsrb/timer-typoRussell Belfer2014-08-051-3/+3
| | | | | The effect of this would be that various update callbacks would not be made at the correct interval.
* Clean up the handling of large binary diffsRussell Belfer2014-05-311-0/+7
|
* React to feedback for UTF-8 <-> WCHAR and reparse workPhilip Kelley2014-04-231-0/+9
|
* Decouple index iterator sort from indexRussell Belfer2014-04-171-0/+1
| | | | | | | | This makes the index iterator honor the GIT_ITERATOR_IGNORE_CASE and GIT_ITERATOR_DONT_IGNORE_CASE flags without modifying the index data itself. To take advantage of this, I had to export a number of the internal index entry comparison functions. I also wrote some new tests to exercise the capability.
* Introduce git__date_rfc2822_fmt. Allows for RFC2822 date headersJacques Germishuys2014-04-111-0/+12
|
* Split p_strlen into its own headerCarlos Martín Nieto2014-02-051-1/+1
| | | | | | | | | We need this from util.h and posix.h, but the latter includes common.h which includes util.h, which means p_strlen is not defined by the time we get to git__strndup(). Split the definition on p_strlen() off into its own header so we can use it in util.h.
* utils: don't reimplement strnlenCarlos Martín Nieto2014-02-051-2/+2
| | | | | The standard library provides a very nice strnlen function, which knows to use SSE, let's not reimplement it ourselves.
* Mark git__timer as inline on OSXBen Straub2013-10-011-1/+1
|
* Initial Implementation of progress reports during pushJameson Miller2013-09-301-0/+61
| | | | | | | | | | | | | | | | | | | | | | This adds the basics of progress reporting during push. While progress for all aspects of a push operation are not reported with this change, it lays the foundation to add these later. Push progress reporting can be improved in the future - and consumers of the API should just get more accurate information at that point. The main areas where this is lacking are: 1) packbuilding progress: does not report progress during deltafication, as this involves coordinating progress from multiple threads. 2) network progress: reports progress as objects and bytes are going to be written to the subtransport (instead of as client gets confirmation that they have been received by the server) and leaves out some of the bytes that are transfered as part of the push protocol. Basically, this reports the pack bytes that are written to the subtransport. It does not report the bytes sent on the wire that are received by the server. This should be a good estimate of progress (and an improvement over no progress).
* vector: Teach git_vector_uniq() to free while deduplicatingnulltoken2013-08-271-1/+4
|
* git_strndup fix when OOMEdward Thomson2013-08-081-0/+3
|
* Major rename detection changesRussell Belfer2013-07-311-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After doing further profiling, I found that a lot of time was being spent attempting to insert hashes into the file hash signature when using the rolling hash because the rolling hash approach generates a hash per byte of the file instead of one per run/line of data. To optimize this, I decided to convert back to a run-based file signature algorithm which would be more like core Git. After changing this, a number of the existing tests started to fail. In some cases, this appears to have been because the test was coded to be too specific to the particular results of the file similarity metric and in some cases there appear to have been bugs in the core rename detection code where only by the coincidence of the file similarity scoring were the expected results being generated. This renames all the variables in the core rename detection code to be more consistent and hopefully easier to follow which made it a bit easier to reason about the behavior of that code and fix the problems that I was seeing. I think it's in better shape now. There are a couple of tests now that attempt to stress test the rename detection code and they are quite slow. Most of the time is spent setting up the test data on disk and in the index. When we roll out performance improvements for index insertion, it should also speed up these tests I hope.
* Add accessors for refcount valueRussell Belfer2013-07-101-0/+3
|
* git__strcasesort_cmp: strcasecmp sorting rules but requires strict equalityEdward Thomson2013-06-171-0/+2
|
* util: git__memzero() tweaksyorah2013-06-171-1/+11
| | | | | | | On Linux: fix a warning message related to the volatile qualifier (cast) On Windows: use SecureZeroMemory() On both, inline the call, so that no entry point can lead back to this "secure" memory zeroing.
* util: It's called `memzero`Vicent Marti2013-06-121-3/+3
|
* Merge remote-tracking branch 'arrbee/minor-paranoia' into developmentVicent Marti2013-06-121-3/+8
|\
| * Add safe memset and use itRussell Belfer2013-06-071-3/+8
| | | | | | | | | | | | This adds a `git__memset` routine that will not be optimized away and updates the places where I memset() right before a free() call to use it.
* | Reorganize diff and add basic diff driverRussell Belfer2013-06-101-0/+2
|/ | | | | | | | | | | | | | | | | | This is a significant reorganization of the diff code to break it into a set of more clearly distinct files and to document the new organization. Hopefully this will make the diff code easier to understand and to extend. This adds a new `git_diff_driver` object that looks of diff driver information from the attributes and the config so that things like function content in diff headers can be provided. The full driver spec is not implemented in the commit - this is focused on the reorganization of the code and putting the driver hooks in place. This also removes a few #includes from src/repository.h that were overbroad, but as a result required extra #includes in a variety of places since including src/repository.h no longer results in pulling in the whole world.
* Fix issues with git_diff_find_similarRussell Belfer2013-05-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a number of bugs in the rename code that only were obvious when I started testing it against large old repos with more complex patterns. (The code to do that testing is not ready to merge with libgit2, but I do plan to add more thorough tests.) This contains a significant number of changes and also tweaks the public API slightly to make emulating core git easier. Most notably, this separates the GIT_DIFF_FIND_AND_BREAK_REWRITES flag into FIND_REWRITES (which adds a self-similarity score to every modified file) and BREAK_REWRITES (which splits the modified deltas into add/remove pairs in the diff list). When you do a raw output of core git, rewrites show up as M090 or such, not at A and D output, so I wanted to be able to emulate that. Publicly, this also changes the flags to be uint16_t since we don't need values out of that range. Internally, this contains significant changes from a number of small bug fixes (like using the wrong side of the diff to decide if the object could be found in the ODB vs the workdir) to larger issues about which files can and should be compared and how the various edge cases of similarity scores should be treated. Honestly, I don't think this is the last update that will have to be made to this code, but I think this moves us closer to correct behavior and I tried to document the code so it would be easier to follow..
* Unify whitespaces to tabsLinquize2013-05-151-4/+4
|
* Make refcounting atomicCarlos Martín Nieto2013-04-221-4/+4
|
* Add git__compare_and_swap and use itRussell Belfer2013-04-221-19/+0
| | | | | | | This removes the lock from the repository object and changes the internals to use the new atomic git__compare_and_swap to update the _odb, _config, _index, and _refdb variables in a threadsafe manner.
* Further threading fixesRussell Belfer2013-04-221-1/+20
| | | | | | | | | | | | | This builds on the earlier thread safety work to make it so that setting the odb, index, refdb, or config for a repository is done in a threadsafe manner with minimized locking time. This is done by adding a lock to the repository object and using it to guard the assignment of the above listed pointers. The lock is only held to assign the pointer value. This also contains some minor fixes to the other work with pack files to reduce the time that locks are being held to and fix an apparently memory leak.
* Move refdb_backend to include/git2/sysRussell Belfer2013-04-211-0/+2
| | | | | | | | | This moves most of the refdb stuff over to the include/git2/sys directory, with some minor shifts in function organization. While I was making the necessary updates, I also removed the trailing whitespace in a few files that I modified just because I was there and it was bugging me.
* Sorting function cleanup and MinGW fixRussell Belfer2013-03-111-5/+7
| | | | | | | 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).
* Make tree iterator handle icase equivalenceRussell Belfer2013-03-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | There is a serious bug in the previous tree iterator implementation. If case insensitivity resulted in member elements being equivalent to one another, and those member elements were trees, then the children of the colliding elements would be processed in sequence instead of in a single flattened list. This meant that the tree iterator was not truly acting like a case-insensitive list. This completely reworks the tree iterator to manage lists with case insensitive equivalence classes and advance through the items in a unified manner in a single sorted frame. It is possible that at a future date we might want to update this to separate the case insensitive and case sensitive tree iterators so that the case sensitive one could be a minimal amount of code and the insensitive one would always know what it needed to do without checking flags. But there would be so much shared code between the two, that I'm not sure it that's a win. For now, this gets what we need. More tests are needed, though.
* signature: Shut up MSVC, you silly gooseVicent Marti2013-02-201-0/+15
|
* Use malloc rather than callocBen Straub2013-02-011-1/+2
|
* Introduce git__substrdupBen Straub2013-02-011-5/+9
|
* Vector improvements and their falloutPhilip Kelley2013-01-271-1/+4
|
* Add payload "_r" versions of bsearch and tsortRussell Belfer2013-01-151-2/+18
| | | | | | | | | 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
|
* fetchhead reading/iteratingEdward Thomson2012-12-191-0/+1
|