Re: [PATCH 2/7] move setting of object-type to alloc_* functions

2014-07-14 Thread Ramsay Jones
On 14/07/14 06:57, Jeff King wrote: On Sun, Jul 13, 2014 at 08:27:51PM +0100, Ramsay Jones wrote: Thinking on this more, writing out the definitions is the only sane thing to do here, now that alloc_commit_node does not use the macro. Otherwise you are inviting people to modify the macro,

Re: [PATCH 2/7] move setting of object-type to alloc_* functions

2014-07-13 Thread Jeff King
On Sat, Jul 12, 2014 at 02:05:39PM -0400, Jeff King wrote: I don't particularly like 'flag' here. (not a massive dislike, mind you:) Perhaps: flag-object_type, type-node_type? Or, if that's too verbose, maybe just: flag-type, type-node? Me either, but as you noticed, type was taken.

Re: [PATCH 2/7] move setting of object-type to alloc_* functions

2014-07-13 Thread Ramsay Jones
On 13/07/14 07:41, Jeff King wrote: On Sat, Jul 12, 2014 at 02:05:39PM -0400, Jeff King wrote: I don't particularly like 'flag' here. (not a massive dislike, mind you:) Perhaps: flag-object_type, type-node_type? Or, if that's too verbose, maybe just: flag-type, type-node? Me either, but

Re: [PATCH 2/7] move setting of object-type to alloc_* functions

2014-07-13 Thread Jeff King
On Sun, Jul 13, 2014 at 08:27:51PM +0100, Ramsay Jones wrote: Thinking on this more, writing out the definitions is the only sane thing to do here, now that alloc_commit_node does not use the macro. Otherwise you are inviting people to modify the macro, but fail to notice that the commit

Re: [PATCH 2/7] move setting of object-type to alloc_* functions

2014-07-12 Thread Ramsay Jones
On 11/07/14 09:46, Jeff King wrote: The struct object type implements basic object polymorphism. Individual instances are allocated as concrete types (or as a union type that can store any object), and a struct object * can be cast into its real type after examining its type enum. This

Re: [PATCH 2/7] move setting of object-type to alloc_* functions

2014-07-12 Thread Ramsay Jones
On 11/07/14 09:46, Jeff King wrote: [snip] Sorry, hit send too early ... diff --git a/blob.c b/blob.c index ae320bd..5720a38 100644 --- a/blob.c +++ b/blob.c @@ -7,7 +7,7 @@ struct blob *lookup_blob(const unsigned char *sha1) { struct object *obj = lookup_object(sha1); if

Re: [PATCH 2/7] move setting of object-type to alloc_* functions

2014-07-12 Thread Jeff King
On Sat, Jul 12, 2014 at 03:44:06PM +0100, Ramsay Jones wrote: - return alloc_node(name##_state, sizeof(type)); \ + return alloc_node(name##_state, flag, sizeof(type)); \ } I don't particularly like 'flag' here. (not a massive dislike, mind you:) Perhaps:

Re: [PATCH 2/7] move setting of object-type to alloc_* functions

2014-07-12 Thread Jeff King
On Sat, Jul 12, 2014 at 03:55:35PM +0100, Ramsay Jones wrote: if (!obj) { struct commit *c = alloc_commit_node(); - return create_object(sha1, OBJ_COMMIT, c); + return create_object(sha1, c); } perhaps: if (!obj) return

[PATCH 2/7] move setting of object-type to alloc_* functions

2014-07-11 Thread Jeff King
The struct object type implements basic object polymorphism. Individual instances are allocated as concrete types (or as a union type that can store any object), and a struct object * can be cast into its real type after examining its type enum. This means it is dangerous to have a type field