From: Matthieu Moy Date: Tue, 15 Jun 2010 10:51:52 GMT Subject: Re: [PATCH v2 2/3] textconv: support for blame Message-ID: In-Reply-To: <192517e06785fed4fa799bee9a11ae28@ensimag.fr> bonneta writes: > But we have to do: > textconv_object(read_from, null_sha1, &buf.buf, (unsigned long *) > &buf.len)) > where buf.len is size_t. > > Is that ok? I don't think it fixes the problem. You're assuming sizeof(unsigned long) == sizeof(size_t), otherwise, textconv_object will write the incorrect number of bytes at the given adress. If you have to use this pass-by-adress, you want size_t buf_len; /* textconv_object needs a last parameter of type (size_t *) */ textconv_object(..., &buf_len); /* <-- no cast here */ buf.len = buf_len; /* This is a cast, but not a pointer cast. The compiler will do the actual conversion if needed (while pointer casts are just a matter of typing, the generate no code). */ -- Matthieu Moy http://www-verimag.imag.fr/~moy/