* Coding style question for Corinna
@ 2020-11-13 6:02 Mark Geisert
2020-11-13 9:22 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Mark Geisert @ 2020-11-13 6:02 UTC (permalink / raw)
To: cygwin-developers
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))
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Coding style question for Corinna
2020-11-13 6:02 Coding style question for Corinna Mark Geisert
@ 2020-11-13 9:22 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2020-11-13 9:22 UTC (permalink / raw)
To: cygwin-developers
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-13 9:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 6:02 Coding style question for Corinna Mark Geisert
2020-11-13 9:22 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).