src/util.c


Log

Author Commit Date CI Message
Vicent Marti f79026b4 2011-07-04T11:43:34 fileops: Cleanup Cleaned up the structure of the whole OS-abstraction layer. fileops.c now contains a set of utility methods for file management used by the library. These are abstractions on top of the original POSIX calls. There's a new file called `posix.c` that contains emulations/reimplementations of all the POSIX calls the library uses. These are prefixed with `p_`. There's a specific posix file for each platform (win32 and unix). All the path-related methods have been moved from `utils.c` to `path.c` and have their own prefix.
Kirill A. Shutemov 932d1baf 2011-06-30T19:52:34 cleanup: remove trailing spaces Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Vicent Marti 536955f9 2011-06-16T02:21:33 Add method to get the compiled version of the lib
Vicent Marti 0291b5b7 2011-06-03T19:59:16 odb: Fix loading ODB alternates Fixed an issue with the `strtokz implementation and added support for comments and relative paths in the alternates file.
nulltoken 3a1c4310 2011-05-24T18:55:35 Fix compilation warnings in MSVC This allows to successfully build libgit2 with waf on Windows.
Jakob Pfender 33b1d19e 2011-05-19T15:13:40 util.c: Move to new error handling mechanism
Vicent Marti 0da2c700 2011-05-17T15:09:30 utils: Move git__str[n]tolower
Vicent Marti c6e65aca 2011-04-09T15:22:11 Properly check `strtol` for errors We are now using a custom `strtol` implementation to make sure we're not missing any overflow errors.
nulltoken 2b861d75 2011-03-19T08:31:40 Add detection of incorrect usage to git__joinpath()
Vicent Marti 955f9ae9 2011-03-16T01:06:15 Export `git_strarray_free` instead of inlining That way non-C bindings can use it.
Vicent Marti 246eba80 2011-03-05T13:58:47 Use memmove() in git__dirname and git__basename We cannot make sure that the user doesn't use the same buffer as source and destination, so write to it using memmove. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 60cb1d10 2011-03-05T13:56:14 Use memmove() in git__joinpath for overlapping copies Signed-off-by: Vicent Marti <tanoku@gmail.com>
nulltoken 669db21b 2011-02-28T22:21:18 Slightly changed the behavior of git__joinpath() and git__joinpath_n().
Vicent Marti 995f9c34 2011-02-09T12:43:19 Use the new git__joinpath to build paths in methods The `git__joinpath` function has been changed to use a statically allocated buffer; we assume the buffer to be 4096 bytes, because fuck you. The new method also supports an arbritrary number of paths to join, which may come in handy in the future. Some methods which were manually joining paths with `strcpy` now use the new function, namely those in `index.c` and `refs.c`. Based on Emeric Fermas' original patch, which was using the old `git__joinpath` because I'm stupid. Thanks! Signed-off-by: Vicent Marti <tanoku@gmail.com>
nulltoken a79e8e63 2011-02-05T19:22:44 Fixed a small issue in git__join_path(). Added tests to exercise git__join_path().
Vicent Marti 412b3887 2011-02-05T13:12:02 Add new utility method `git__joinpath` Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti f725931b 2011-02-05T12:42:41 Fix directory/path manipulation methods The `dirname` and `dirbase` methods have been replaced with the Android implementation, which is actually compilant to some kind of standard. A new method `topdir` has been added, which returns the topmost directory in a path. These changes fix issue #49: `gitfo_prettify_dir_path` converts "./.git/" to ".git/", so the code at src/repository.c:190 goes out of bounds when trying to find the topmost directory. The new `git__topdir` method handles this gracefully, and the fixed `git__dirname` now returns the proper value for the repository's working dir. E.g. /repo/.git/ ==> working dir '/repo/' .git/ ==> working dir '.' Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti e0646b38 2010-12-30T00:31:58 Add generic hash function to util.c It's MurmurHash3 slightly edited to make it cross-platform. Fast and neat. Use this for hashing strings on hash tables instead of a full SHA1 hash. It's very fast and well distributed. Obviously not crypto-secure. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 9f54fe48 2010-12-23T00:15:09 Remove git_errno It was not being used by any methods (only by malloc and calloc), and since it needs to be TLS, it cannot be exported on DLLs on Windows. Burn it with fire. The API always returns error codes! Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 69a09b7c 2010-11-19T17:17:46 Fix wrong pointer check in git__strdup Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Marti 0e465f97 2010-08-12T18:47:32 Add auxiliary method git__hexdump New function in util.c to do a dump of a buffer's contents in hexadecimal to stdout. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Ramsay Jones 0ef9d2aa 2010-01-03T22:56:54 Fix some "signed v unsigned comparison" warnings with -Wextra Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Ramsay Jones 10aa3fa7 2009-06-04T17:14:35 Fix some "signed/unsigned mismatch" (msvc) compiler warnings Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Andreas Ericsson <ae@op5.se>
Ramsay Jones a9984a4e 2009-02-18T18:52:13 Fix some (digital-mars) compiler warnings In particular, conditional expressions which contain an assignment statement, where the expression type is not explicitly made to be boolean, elicits the following message: warning 2: possible unintended assignment Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones ced645ea 2009-01-12T19:42:13 Add git__dirname and git__basename utility routines These routines are intended to extract the directory and base name from a path string. Note that these routines do not interact with any filesystem and work only on the text of the path. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 2c4b7707 2008-12-31T16:06:48 Add git__fmt as an easier to use snprintf Checking the return value of snprintf is a pain, as it must be >= 0 and < sizeof(buffer). git__fmt is a simple wrapper to perform these checks. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 9eb79764 2008-12-31T14:35:39 Add string utility functions for prefix and suffix compares Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce 64a47c01 2008-12-30T23:21:36 Wrap malloc and friends and report out of memory as GIT_ENOMEM We now forbid direct use of malloc, strdup or calloc within the library and instead use wrapper functions git__malloc, etc. to invoke the underlying library malloc and set git_errno to a no memory error code if the allocation fails. In the future once we have pack objects in memory we are likely to enhance these routines with garbage collection logic to purge cached pack data when allocations fail. Because the size of the function will grow somewhat large, we don't want to mark them for inline as gcc tends to aggressively inline, creating larger than expected executables. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>