formalize typename(), and add its reverse type_from_string()
Sometime typename() is used, sometimes type_names[] is accessed directly. Let's enforce typename() all the time which allows for validating the type. Also let's add a function to go from a name to a type and use it instead of manual memcpy() when appropriate. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:

committed by
Junio C Hamano

parent
9ba630318f
commit
df8436622f
@ -196,7 +196,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
|
||||
if (deref)
|
||||
name++;
|
||||
if (!strcmp(name, "objecttype"))
|
||||
v->s = type_names[obj->type];
|
||||
v->s = typename(obj->type);
|
||||
else if (!strcmp(name, "objectsize")) {
|
||||
char *s = xmalloc(40);
|
||||
sprintf(s, "%lu", sz);
|
||||
|
Reference in New Issue
Block a user