git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [Outreachy] Return value before or after free()?
@ 2020-01-06 21:15 Miriam R.
  2020-01-06 21:30 ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Miriam R. @ 2020-01-06 21:15 UTC (permalink / raw)
  To: git

Dear all,
in run-command.c file `exists_in_PATH()` function does this:

static int exists_in_PATH(const char *file)
{
char *r = locate_in_PATH(file);
free(r);
return r != NULL;
}

I wonder if it is correct to do return r != NULL; after free(r);

Could be this version more readable? :

static int exists_in_PATH(const char *file)
{
char *r = locate_in_PATH(file);
int res = (r != NULL);
free(r);
return res;
}

Could you please give me your feedback?

Thank you!

Best,
Miriam.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-07 20:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-06 21:15 [Outreachy] Return value before or after free()? Miriam R.
2020-01-06 21:30 ` Jeff King
2020-01-06 22:47   ` Jonathan Nieder
2020-01-06 23:34   ` Andreas Schwab
2020-01-07  1:08   ` brian m. carlson
2020-01-07  1:58     ` brian m. carlson
2020-01-07 20:40       ` Miriam R.

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).