git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: git@vger.kernel.org
Cc: Ramkumar Ramachandra <artagnon@gmail.com>,
	David Barr <david.barr@cordelta.com>
Subject: [PATCH/RFC 0/8] Remove various dependencies from wrapper.o
Date: Sat, 6 Nov 2010 06:39:05 -0500	[thread overview]
Message-ID: <20101106113905.GA27405@burratino> (raw)

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

-- 
1.7.2.3.557.gab647.dirty

             reply	other threads:[~2010-11-06 11:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-06 11:39 Jonathan Nieder [this message]
2010-11-06 11:44 ` [PATCH 1/8] wrapper: move xmmap() to sha1_file.c Jonathan Nieder
2010-11-06 11:45 ` [PATCH 2/8] wrapper: move odb_* to environment.c Jonathan Nieder
2010-11-06 11:46 ` [PATCH 3/8] path helpers: move git_mkstemp* to wrapper.c Jonathan Nieder
2010-11-06 11:46 ` [PATCH 4/8] strbuf: move strbuf_branchname to sha1_name.c Jonathan Nieder
2010-11-06 11:47 ` [PATCH 5/8] wrapper: give zlib wrappers their own translation unit Jonathan Nieder
2010-11-06 11:47 ` [PATCH 6/8] pack-objects: mark file-local variable static Jonathan Nieder
2010-11-06 11:48 ` [PATCH 7/8] wrapper: expose try_to_free_pack_memory() Jonathan Nieder
2010-11-06 11:52 ` [PATCH 8/8] Remove pack file handling dependency from wrapper.o Jonathan Nieder
2010-11-06 18:07   ` René Scharfe
2010-11-06 18:42     ` Jonathan Nieder
2010-11-07 16:10       ` René Scharfe
2010-11-07 18:23         ` Jonathan Nieder
2010-11-06 19:00     ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101106113905.GA27405@burratino \
    --to=jrnieder@gmail.com \
    --cc=artagnon@gmail.com \
    --cc=david.barr@cordelta.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).