On 08/09/2011 02:32 PM, Steve Ellcey wrote: > On Tue, 2011-08-09 at 08:25 -0700, Richard Henderson wrote: >> On 08/08/2011 03:22 PM, Steve Ellcey wrote: >>> Oh, so after I declare md5, I call md5_finish_ctx like: >>> >>> md5_finish_ctx (&md5.ctx, md5.checksum); >>> >>> Is that what you are proposing? It seems a bit odd to put checksum in a >>> a structure with ctx just to guarantee its alignment and not to pass >>> them around as one entity, but I guess it's no worse then using a union. >> >> Yes, that's what I'm proposing. >> >> >> r~ > > I think I like using a union to ensure the alignment of checksum better. > In dwarf2out.c we are always using one md5_ctx structure and one > checksum buffer but in fold-const.c there are routines where we use one > md5_ctx structure with 4 (fold_build2_stat_loc) or 6 > (fold_build3_stat_loc) different checksum buffers.
I'm not keen on this. Yes, it does happen to work, but only accidentally. The CTX object and the CHECKSUM object have overlapping lifetimes within md5_read_ctx. r~