threads / patch / 21981

patch, 2 partstechnical-docs: document hash API

Subject: [PATCH 2/2] technical-docs: document hash API

## tl;dr

3 messages between Dec 18, 2009 and Dec 18, 2009. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Stephen Boyd· Dec 18, 2009, 00:05 UTC · lore

[PATCH 1/2] api-strbuf.txt: fix typos and document launch_editor()

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
 Documentation/technical/api-strbuf.txt |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
Show changes to Documentation/technical/api-strbuf.txt +8 −2
diff --git a/Documentation/technical/api-strbuf.txt b/Documentation/technical/api-strbuf.txt
index 7438149..a0e0f85 100644
--- a/Documentation/technical/api-strbuf.txt
+++ b/Documentation/technical/api-strbuf.txt
@@ -12,7 +12,7 @@ strbuf API actually relies on the string being free of NULs.
 
 strbufs has some invariants that are very important to keep in mind:
 
-. The `buf` member is never NULL, so you it can be used in any usual C
+. The `buf` member is never NULL, so it can be used in any usual C
 string operations safely. strbuf's _have_ to be initialized either by
 `strbuf_init()` or by `= STRBUF_INIT` before the invariants, though.
 +
@@ -55,7 +55,7 @@ Data structures
 
 * `struct strbuf`
 
-This is string buffer structure. The `len` member can be used to
+This is the string buffer structure. The `len` member can be used to
 determine the current length of the string, and `buf` member provides access to
 the string itself.
 
@@ -253,3 +253,9 @@ same behaviour as well.
 	comments are considered contents to be removed or not.
 
 `launch_editor`::
+
+	Launch the user preferred editor to edit a file and fill the buffer
+	with the file's contents upon the user completing their editing. The
+	third argument can be used to set the environment which the editor is
+	run in. If the buffer is NULL the editor is launched as usual but the
+	file's contents are not read into the buffer upon completion.
-- 
1.6.6.rc3.1.g8df51
Stephen Boyd· Dec 18, 2009, 00:05 UTC · re: Stephen Boyd · lore
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
 Documentation/technical/api-hash.txt |   50 ++++++++++++++++++++++++++++++++-
 1 files changed, 48 insertions(+), 2 deletions(-)
Show changes to Documentation/technical/api-hash.txt +48 −2
diff --git a/Documentation/technical/api-hash.txt b/Documentation/technical/api-hash.txt
index c784d3e..e5061e0 100644
--- a/Documentation/technical/api-hash.txt
+++ b/Documentation/technical/api-hash.txt
@@ -1,6 +1,52 @@
 hash API
 ========
 
-Talk about <hash.h>
+The hash API is a collection of simple hash table functions. Users are expected
+to implement their own hashing.
 
-(Linus)
+Data Structures
+---------------
+
+`struct hash_table`::
+
+	The hash table structure. The `array` member points to the hash table
+	entries. The `size` member counts the total number of valid and invalid
+	entries in the table. The `nr` member keeps track of the number of
+	valid entries.
+
+`struct hash_table_entry`::
+
+	An opaque structure representing an entry in the hash table. The `hash`
+	member is the entry's hash key and the `ptr` member is the entry's
+	value.
+
+Functions
+---------
+
+`init_hash`::
+
+	Initialize the hash table.
+
+`free_hash`::
+
+	Release memory associated with the hash table.
+
+`insert_hash`::
+
+	Insert a pointer into the hash table. If an entry with that hash
+	already exists, a pointer to the existing entry's value is returned.
+	Otherwise NULL is returned.  This allows callers to implement
+	chaining, etc.
+
+`lookup_hash`::
+
+	Lookup an entry in the hash table. If an entry with that hash exists
+	the entry's value is returned. Otherwise NULL is returned.
+
+`for_each_hash`::
+
+	Call a function for each entry in the hash table. The function is
+	expected to take the entry's value as its only argument and return an
+	int. If the function returns a negative int the loop is aborted
+	immediately.  Otherwise, the return value is accumulated and the sum
+	returned upon completion of the loop.
-- 
1.6.6.rc3.1.g8df51
Miklos Vajna· Dec 18, 2009, 00:42 UTC · re: Stephen Boyd · lore

Re: [PATCH 1/2] api-strbuf.txt: fix typos and document launch_editor()

On Thu, Dec 17, 2009 at 04:05:28PM -0800, Stephen Boyd <bebarino@gmail.com> wrote:
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
> ---
>  Documentation/technical/api-strbuf.txt |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)

Thanks, I really should have read these sentences once again before sending them in. ;-)

← back to recent threads