Re: [PATCH 12/18] alternates: use a separate scratch space

2 messages, 2 authors, 2016-10-04 · open the first message on its own page

Re: [PATCH 12/18] alternates: use a separate scratch space

From: Junio C Hamano <hidden>
Date: 2016-10-04 21:29:54

Jeff King [off-list ref] writes:
 extern struct alternate_object_database {
 	struct alternate_object_database *next;
+
 	char *name;
-	char base[FLEX_ARRAY]; /* more */
+	char *scratch;
+
+	char path[FLEX_ARRAY];
 } *alt_odb_list;
It is not wrong per-se, but I am a bit surprised to see that the
code keeps FLEX_ARRAY _and_ uses a separate malloc'ed area pointed
at by the scratch pointer.

Loss of "compare only up to the location 'name' points at" makes the
users of the struct that want only the directory path certainly a
lot simpler and easier to follow.

Thanks.

Re: [PATCH 12/18] alternates: use a separate scratch space

From: Jeff King <hidden>
Date: 2016-10-04 21:32:48

On Tue, Oct 04, 2016 at 02:29:46PM -0700, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
 extern struct alternate_object_database {
 	struct alternate_object_database *next;
+
 	char *name;
-	char base[FLEX_ARRAY]; /* more */
+	char *scratch;
+
+	char path[FLEX_ARRAY];
 } *alt_odb_list;
It is not wrong per-se, but I am a bit surprised to see that the
code keeps FLEX_ARRAY _and_ uses a separate malloc'ed area pointed
at by the scratch pointer.
Yeah, there's really no reason "path" could not become a non-flex
buffer. I mostly left it there out of inertia. If you have a preference,
I'm happy to change it.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help