Coding style question for Corinna
Corinna Vinschen
corinna-cygwin@cygwin.com
Fri Nov 13 09:22:06 GMT 2020
Hi Mark,
On Nov 12 22:02, Mark Geisert wrote:
> Hi Corinna,
> I'm about to submit the patches for a small improvement to Cygwin's malloc
> implementation. There are several places in malloc_wrapper.cc where I have
> minor code repetition inside an #if. But it could be coded differently.. so
> which of the following forms do you prefer?
> --- form 1 ---
> if (!use_internal)
> user_data->free (p);
> else
> {
> #if MSPACES
> void *m = get_current_mspace ();
> if (likely(m))
^^^
missing space
> mspace_free (m, p);
> else
> dlfree (p);
> #else
> dlfree (p);
> #endif
> }
>
> --- form 2 ---
> if (!use_internal)
> user_data->free (p);
> else
> {
> #if MSPACES
> void *m = get_current_mspace ();
> if (likely(m))
> mspace_free (m, p);
> else
> #endif
> dlfree (p);
> }
>
> Thanks,
>
> ..mark
We have a couple of form 2 in the code, but I'd prefer form 1 these
days. However, you're doing the coding and both forms are correct, so
it's your choice in the first place.
Corinna
More information about the Cygwin-developers
mailing list