<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/hashmap.h, branch v2.23.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.23.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.23.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2019-06-20T17:44:22Z</updated>
<entry>
<title>hashmap: convert sha1hash() to oidhash()</title>
<updated>2019-06-20T17:44:22Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-06-20T07:41:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d40abc8e95f75b529feb140178b69a3783c2d108'/>
<id>urn:sha1:d40abc8e95f75b529feb140178b69a3783c2d108</id>
<content type='text'>
There are no callers left of sha1hash() that do not simply pass the
"hash" member of a "struct object_id". Let's get rid of the outdated
sha1-specific function and provide one that operates on the whole struct
(even though the technique, taking the first few bytes of the hash, will
remain the same).

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>*.[ch]: remove extern from function declarations using spatch</title>
<updated>2019-05-05T06:20:06Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2019-04-29T08:28:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=554544276a604c144df45efcb060c80aa322088c'/>
<id>urn:sha1:554544276a604c144df45efcb060c80aa322088c</id>
<content type='text'>
There has been a push to remove extern from function declarations.
Remove some instances of "extern" for function declarations which are
caught by Coccinelle. Note that Coccinelle has some difficulty with
processing functions with `__attribute__` or varargs so some `extern`
declarations are left behind to be dealt with in a future patch.

This was the Coccinelle patch used:

	@@
	type T;
	identifier f;
	@@
	- extern
	  T f(...);

and it was run with:

	$ git ls-files \*.{c,h} |
		grep -v ^compat/ |
		xargs spatch --sp-file contrib/coccinelle/noextern.cocci --in-place

Files under `compat/` are intentionally excluded as some are directly
copied from external sources and we should avoid churning them as much
as possible.

Signed-off-by: Denton Liu &lt;liu.denton@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rb/hashmap-h-compilation-fix'</title>
<updated>2018-02-13T21:39:10Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2018-02-13T21:39:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=922ffec6fe52b4aa6f4664b01f2166066ed8c260'/>
<id>urn:sha1:922ffec6fe52b4aa6f4664b01f2166066ed8c260</id>
<content type='text'>
Code clean-up.

* rb/hashmap-h-compilation-fix:
  hashmap.h: remove unused variable
</content>
</entry>
<entry>
<title>hashmap.h: remove unused variable</title>
<updated>2018-01-16T22:27:07Z</updated>
<author>
<name>Randall S. Becker</name>
<email>rsbecker@nexbridge.com</email>
</author>
<published>2018-01-14T18:07:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7d68bb0766120208f4281f278aac80ebd9951e5c'/>
<id>urn:sha1:7d68bb0766120208f4281f278aac80ebd9951e5c</id>
<content type='text'>
In 'hashmap_enable_item_counting()', item is assigned but never
used.  This causes a warning on HP NonStop.  As the variable is
never used, fix this by just removing it.

Signed-off-by: Randall S. Becker &lt;rsbecker@nexbridge.com&gt;
Helped-by: Thomas Gummerer &lt;t.gummerer@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hashmap: adjust documentation to reflect reality</title>
<updated>2017-12-05T21:37:43Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2017-11-29T23:51:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=826c778f7c3bd6c8356a8ecfd1cb0e4326fcf1d8'/>
<id>urn:sha1:826c778f7c3bd6c8356a8ecfd1cb0e4326fcf1d8</id>
<content type='text'>
The hashmap API is just complicated enough that even at least one
long-time Git contributor has to look up how to use it every time he
finds a new use case. When that happens, it is really useful if the
provided example code is correct...

While at it, "fix a memory leak", avoid statements before variable
declarations, fix a const -&gt; no-const cast, several %l specifiers (which
want to be %ld), avoid using an undefined constant, call scanf()
correctly, use FLEX_ALLOC_STR() where appropriate, and adjust the style
here and there.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Reviewed-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hashmap: add API to disable item counting when threaded</title>
<updated>2017-09-07T00:42:02Z</updated>
<author>
<name>Jeff Hostetler</name>
<email>jeffhost@microsoft.com</email>
</author>
<published>2017-09-06T15:43:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8b604d19515c4be18403047045faa363d4de217b'/>
<id>urn:sha1:8b604d19515c4be18403047045faa363d4de217b</id>
<content type='text'>
This is to address concerns raised by ThreadSanitizer on the mailing list
about threaded unprotected R/W access to map.size with my previous "disallow
rehash" change (0607e10009ee4e37cb49b4cec8d28a9dda1656a4).

See:
https://public-inbox.org/git/adb37b70139fd1e2bac18bfd22c8b96683ae18eb.1502780344.git.martin.agren@gmail.com/

Add API to hashmap to disable item counting and thus automatic rehashing.
Also include API to later re-enable them.

When item counting is disabled, the map.size field is invalid.  So to
prevent accidents, the field has been renamed and an accessor function
hashmap_get_size() has been added.  All direct references to this
field have been been updated.  And the name of the field changed
to map.private_size to communicate this.

Here is the relevant output from ThreadSanitizer showing the problem:

WARNING: ThreadSanitizer: data race (pid=10554)
  Read of size 4 at 0x00000082d488 by thread T2 (mutexes: write M16):
    #0 hashmap_add hashmap.c:209
    #1 hash_dir_entry_with_parent_and_prefix name-hash.c:302
    #2 handle_range_dir name-hash.c:347
    #3 handle_range_1 name-hash.c:415
    #4 lazy_dir_thread_proc name-hash.c:471
    #5 &lt;null&gt; &lt;null&gt;

  Previous write of size 4 at 0x00000082d488 by thread T1 (mutexes: write M31):
    #0 hashmap_add hashmap.c:209
    #1 hash_dir_entry_with_parent_and_prefix name-hash.c:302
    #2 handle_range_dir name-hash.c:347
    #3 handle_range_1 name-hash.c:415
    #4 handle_range_dir name-hash.c:380
    #5 handle_range_1 name-hash.c:415
    #6 lazy_dir_thread_proc name-hash.c:471
    #7 &lt;null&gt; &lt;null&gt;

Martin gives instructions for running TSan on test t3008 in this post:
https://public-inbox.org/git/CAN0heSoJDL9pWELD6ciLTmWf-a=oyxe4EXXOmCKvsG5MSuzxsA@mail.gmail.com/

Signed-off-by: Jeff Hostetler &lt;jeffhost@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hashmap: migrate documentation from Documentation/technical into header</title>
<updated>2017-06-30T20:11:59Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2017-06-30T19:14:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1ecbf31d0298a1ed952623108e23234d5cf37086'/>
<id>urn:sha1:1ecbf31d0298a1ed952623108e23234d5cf37086</id>
<content type='text'>
While at it, clarify the use of `key`, `keydata`, `entry_or_key` as well
as documenting the new data pointer for the compare function.

Rework the example.

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hashmap.h: compare function has access to a data field</title>
<updated>2017-06-30T19:49:28Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2017-06-30T19:14:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7663cdc86c860d5b5293a1dd4b0fb6c4e006d08e'/>
<id>urn:sha1:7663cdc86c860d5b5293a1dd4b0fb6c4e006d08e</id>
<content type='text'>
When using the hashmap a common need is to have access to caller provided
data in the compare function. A couple of times we abuse the keydata field
to pass in the data needed. This happens for example in patch-ids.c.

This patch changes the function signature of the compare function
to have one more void pointer available. The pointer given for each
invocation of the compare function must be defined in the init function
of the hashmap and is just passed through.

Documentation of this new feature is deferred to a later patch.
This is a rather mechanical conversion, just adding the new pass-through
parameter.  However while at it improve the naming of the fields of all
compare functions used by hashmaps by ensuring unused parameters are
prefixed with 'unused_' and naming the parameters what they are (instead
of 'unused' make it 'unused_keydata').

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hashmap: add disallow_rehash setting</title>
<updated>2017-03-22T20:41:41Z</updated>
<author>
<name>Jeff Hostetler</name>
<email>jeffhost@microsoft.com</email>
</author>
<published>2017-03-22T17:14:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0607e10009ee4e37cb49b4cec8d28a9dda1656a4'/>
<id>urn:sha1:0607e10009ee4e37cb49b4cec8d28a9dda1656a4</id>
<content type='text'>
Teach hashmap to allow rehashes to be suppressed.
This is useful when hashmaps are accessed by multiple
threads.  It still requires the caller to properly
manage their locking.  This just prevents unexpected
rehashing during inserts and deletes.

Signed-off-by: Jeff Hostetler &lt;jeffhost@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hashmap: allow memihash computation to be continued</title>
<updated>2017-03-22T20:41:41Z</updated>
<author>
<name>Jeff Hostetler</name>
<email>jeffhost@microsoft.com</email>
</author>
<published>2017-03-22T17:14:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f75619bd6d21760e1da416d4e27bce6468beffcd'/>
<id>urn:sha1:f75619bd6d21760e1da416d4e27bce6468beffcd</id>
<content type='text'>
Add variant of memihash() to allow the hash computation to
be continued.  There are times when we compute the hash on
a full path and then the hash on just the path to the parent
directory.  This can be expensive on large repositories.

With this, we can hash the parent directory first. And then
continue the computation to include the "/filename".

Signed-off-by: Jeff Hostetler &lt;jeffhost@microsoft.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
