Re: [PATCH v3 2/3] config: add hashtable for config parsing & retrieval
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jun 23, 2014, 11:55 UTC
- Message-ID
- <vpqtx7bn8ln.fsf@anie.imag.fr>
- In-Reply-To
- <1403518300-23053-3-git-send-email-tanayabh@gmail.com>
Tanay Abhra <tanayabh@gmail.com> writes:
> +/* for NULL values, 'util' for each `string_list_item` is flagged as 1 */
It's a void *, so just saying that it is flagged as 1 does not say how it's encoded. How about "... is an 'int *' pointing to the value 1".
And actually, you can save one malloc by encoding the value directly in the util pointer itself like
#define NULL_FLAG (void *)1
item->util = NULL_FLAG;
I find this a bit ugly, but I think Git already uses this in a few places (git grep 'void \*) *1' for examples).
Or you can use a pointer to a single static value:
static const int boolean_null_flag = 1; // Or even without = 1.
and then
item->util = &boolean_null_flag;
-- Matthieu Moy http://www-verimag.imag.fr/~moy/