Skip to contentSkip to conversation

Two small comment fixes.

PATCH In review Han-Wen Nienhuys 3 participants 5 messages Sep 21, 2017

lore
Share & tools
lore
#0 lore raw

cover Two small comment fixes.

Han-Wen Nienhuys (2):
Fix typo in submodule.h
Document the string_list structure

 string-list.h | 6 ++++++
 submodule.h   | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

--
2.14.1.821.g8fa685d3b7-goog

#1 lore raw

PATCH 1/2 Fix typo in submodule.h

---
 submodule.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
submodule.h +1 -1
index 6b52133c8..f0da0277a 100644
@@ -120,7 +120,7 @@ extern int submodule_move_head(const char *path,
 
 /*
  * Prepare the "env_array" parameter of a "struct child_process" for executing
- * a submodule by clearing any repo-specific envirionment variables, but
+ * a submodule by clearing any repo-specific environment variables, but
  * retaining any config in the environment.
  */
 extern void prepare_submodule_repo_env(struct argv_array *out);
Signature · 1 line
2.14.1.821.g8fa685d3b7-goog
#2 lore raw

PATCH 2/2 Document the string_list structure

In reply to Han-Wen Nienhuys
---
 string-list.h | 6 ++++++
 1 file changed, 6 insertions(+)
string-list.h +6 -0
index 29bfb7ae4..08b534166 100644
@@ -8,6 +8,12 @@ struct string_list_item {
 
 typedef int (*compare_strings_fn)(const char *, const char *);
 
+/* A resizable array of strings. The strings are owned if
+ * 'strdup_strings' is set. It can be used as a sorted array, and a
+ * custom comparison may be given in 'cmp'. The field 'items[i].util'
+ * may be used to implement an array of pairs. In that case, the
+ * caller is responsible for managing memory pointed to by 'util'.
+ */
 struct string_list {
 	struct string_list_item *items;
 	unsigned int nr, alloc;
Signature · 1 line
2.14.1.821.g8fa685d3b7-goog
#3 lore raw

Re: [PATCH 2/2] Document the string_list structure

Quoted 12 lines · Han-Wen Nienhuys
---
 string-list.h | 6 ++++++
 1 file changed, 6 insertions(+)
string-list.h +0 -0
index 29bfb7ae4..08b534166 100644
@@ -8,6 +8,12 @@ struct string_list_item {
 
 typedef int (*compare_strings_fn)(const char *, const char *);

string-list.h struct string_list_item { · line 19

Quoted 10 lines
string-list.h +6 -0
 
+/* A resizable array of strings. The strings are owned if
+ * 'strdup_strings' is set. It can be used as a sorted array, and a
+ * custom comparison may be given in 'cmp'. The field 'items[i].util'
+ * may be used to implement an array of pairs. In that case, the
+ * caller is responsible for managing memory pointed to by 'util'.
+ */
 struct string_list {
 	struct string_list_item *items;
 	unsigned int nr, alloc;

There's a considerable amount of documentation for string-list in Documentation/technical/api-string-list.txt.

Perhaps we should look at migrating it into string-list.h, where it's more likely to be found (and kept up to date). We did something similar for strbuf.h a while back, and I think the result is much better. See the commits in:

git log bdfdaa4978^..d468fa2721

for an example.

-Peff

#4 lore raw

Re: [PATCH 2/2] Document the string_list structure

In reply to Han-Wen Nienhuys
Quoted 10 lines · Han-Wen Nienhuys
---
 string-list.h | 6 ++++++
 1 file changed, 6 insertions(+)
string-list.h +0 -0
index 29bfb7ae4..08b534166 100644

string-list.h struct string_list_item { · line 11

Quoted 4 lines
string-list.h +1 -0
@@ -8,6 +8,12 @@ struct string_list_item {
 
 typedef int (*compare_strings_fn)(const char *, const char *);
 
+/* A resizable array of strings. The strings are owned if

nit: the start of the comment block should be on its own line:

/*
* A resizable ...

string-list.h struct string_list_item { · line 16

Quoted 5 lines
string-list.h +5 -0
+ * 'strdup_strings' is set. It can be used as a sorted array, and a
+ * custom comparison may be given in 'cmp'. The field 'items[i].util'
+ * may be used to implement an array of pairs. In that case, the
+ * caller is responsible for managing memory pointed to by 'util'.
+ */

The util field can be freed if 'free_util' is set when calling string_list_clear() but yeah, in general the caller is managing that memory especially if a complex free function is required (in the case of allocating a struct with dynamically allocated fields to be stored in the util feild).

Just pointing that out, and I'm happy with this and the previous patch.

Quoted 6 lines
string-list.h +0 -0
 struct string_list {
 	struct string_list_item *items;
 	unsigned int nr, alloc;
Signature · 1 line
2.14.1.821.g8fa685d3b7-goog
Signature · 1 line
Brandon Williams