From: Junio C Hamano Date: Fri, 06 Jun 2008 23:09:42 GMT Subject: Re: [PATCH v2] builtin-fast-export: Add importing and exporting of revision marks Message-ID: <7v8wxirwi1.fsf@gitster.siamese.dyndns.org> In-Reply-To: <1212663163-43064-1-git-send-email-pdebie@ai.rug.nl> Pieter de Bie writes: > +static void export_marks(char *file) > +{ > + unsigned int i; > + uint32_t mark; > + struct object_decoration *deco = idnums.hash; > + FILE *f; > + > + f = fopen(file, "w"); > + if (!f) > + error("Unable to open marks file %s for writing", file); > + > + for (i = 0; i < idnums.size; ++i) { > + deco++; > ... > + mark = (uint32_t *)deco->decoration - (uint32_t *)NULL; > + fprintf(f, ":%u %s\n", mark, > + sha1_to_hex(deco->base->sha1)); > ... > +} > + > +static void import_marks(char * input_file) > ... > + add_decoration(&idnums, object, ((uint32_t *)NULL) + mark); I am confused. The type of object_decoration.decorattion is a (void*). Why isn't it sufficient to do it in a naïve and straightforward way? mark = (uint32_t)(deco->decoration); add_decoration(&idnums, object, (void*) mark); Is this twisted pointer arithmetic done in order to avoid cast between int and pointer of different size in the code? Even if that is the case, doesn't "(uint32_t *)deco->decoration - (uint32_t *)NULL" mean the value range for deco->decoration is one-fourth of U32? What are you gaining from using "uint32_t *" instead of some other pointer types, say "char *"?