Remove various dependencies from wrapper.o
Get series with b4
b4 am 20101106113905.GA27405@burratinoVersions newest first
- v1 Latest8 patches 5 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/8 | wrapper: move xmmap() to sha1_file.csha1_file.c wrapper.c | +15 | 0 replies | |
| 2/8 | wrapper: move odb_* to environment.cenvironment.c git-compat-util.h wrapper.c | +38 | 0 replies | |
| 3/8 | path helpers: move git_mkstemp* to wrapper.cpath.c wrapper.c | +113 | 0 replies | |
| 4/8 | strbuf: move strbuf_branchname to sha1_name.csha1_name.c strbuf.c | +16 | 0 replies | |
| 5/8 | wrapper: give zlib wrappers their own translation unitMakefile wrapper.c zlib.c | +62 | 0 replies | |
| 6/8 | pack-objects: mark file-local variable staticbuiltin/ | +1 | 0 replies | |
| 7/8 | wrapper: expose try_to_free_pack_memory()git-compat-util.h sha1_file.c wrapper.c | +7 | 0 replies | |
| 8/8 | Remove pack file handling dependency from wrapper.ocheck-racy.c contrib/ daemon.c +11 more | +21 | 5 replies |
Reviews trailers per patch
None of the 8 patches has a Reviewed-by or Acked-by.
| Patch | René Scharfe |
|---|---|
| 1/8 | |
| 2/8 | |
| 3/8 | |
| 4/8 | |
| 5/8 | |
| 6/8 | |
| 7/8 | |
| 8/8 | Improved-by |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH/RFC 0/8] Remove various dependencies from wrapper.o
Hi,
Ram noticed that using any function from strbuf.c results in a larger binary that requires -lz to link, which is pretty far from ideal. This patch series moves code around to make that no longer the case.
Vaguely inspired by [1].
After applying these patches, you can write:
#define SHA1_HEADER "block-sha1/sha1.h"
#include "cache.h"
int main(void)
{
volatile char *p = xmalloc(5);
return 0;
}and build it with
cc -Wall -W test.c wrapper.o usage.o
-- no libz needed, no sha1 library, no environment.c, small binary.
Of course, making the linker happy tends to make the code clearer, too.
Patch 1 moves xmmap to sha1_file.c, where release_pack_memory() is defined. If xmmap were used by tiny programs, maybe it would make sense to replace release_pack_memory() with a callback, but this is simpler.
Patch 2 moves odb_mkstemp and odb_pack_keep to environment.c, were they have access to the cached value of $GIT_OBJECT_DIRECTORY.
Patch 3 moves git_mkstemps_mode et al from path.c to wrapper.c, so xmkstemp_mode does not have to depend on path.c.
Patch 4 moves some refname-related functions from strbuf.c to sha1_name.c.
Patch 5 moves git_inflate et al to a new zlib.c, so wrapper.o does not have to depend directly on libz.
Patch 6 is a missing "static" keyword. It probably doesn't belong in this series, but it fits okay.
Patch 7 moves try_to_free_builtin to sha1_file.c and adds a declaration for it to git-compat-util.h.
Patch 8 stops referring to try_to_free_builtin from wrapper.c, completing the project.
Thoughts? Improvements? Benchmarks?
[1] http://thread.gmane.org/gmane.comp.version-control.git/137686/focus=137737
Jonathan Nieder (8):
wrapper: move xmmap() to sha1_file.c
wrapper: move odb_* to environment.c
path helpers: move git_mkstemp* to wrapper.c
strbuf: move strbuf_branchname to sha1_name.c
wrapper: give zlib wrappers their own translation unit
pack-objects: mark file-local variable static
wrapper: expose try_to_free_pack_memory() Remove pack file handling dependency from wrapper.o
Makefile | 1 + builtin/pack-objects.c | 2 +- check-racy.c | 1 + contrib/convert-objects/convert-objects.c | 1 + daemon.c | 1 + environment.c | 37 ++++++ fast-import.c | 1 + git-compat-util.h | 2 + git.c | 2 + http-backend.c | 1 + http-fetch.c | 1 + http-push.c | 1 + imap-send.c | 1 + path.c | 113 ---------------- remote-curl.c | 1 + sha1_file.c | 20 +++ sha1_name.c | 16 +++ strbuf.c | 16 --- test-dump-cache-tree.c | 4 +- test-match-trees.c | 1 + upload-pack.c | 1 + wrapper.c | 198 ++++++++++++++-------------- zlib.c | 61 +++++++++ 23 files changed, 253 insertions(+), 230 deletions(-) create mode 100644 zlib.c
Signature · 1 line
1.7.2.3.557.gab647.dirty