All of lore.kernel.org
 help / color / mirror / Atom feed
From: richard.purdie@linuxfoundation.org
To: Jaewon Lee <jaewon.lee@xilinx.com>,
	 openembedded-core@lists.openembedded.org, manjukum@xilinx.com,
	 alejandr@xilinx.com
Subject: Re: [master][RFC] Adding back wrapper and using OEPYTHON3HOME variable for python3
Date: Thu, 25 Apr 2019 21:50:21 +0100	[thread overview]
Message-ID: <72e102b7e2a14c0747e3b485a6429f8dde546508.camel@linuxfoundation.org> (raw)
In-Reply-To: <1556222193-2780-1-git-send-email-jaewon.lee@xilinx.com>

On Thu, 2019-04-25 at 12:56 -0700, Jaewon Lee wrote:
> +diff --git a/Modules/main.c b/Modules/main.c
> +index a745381..25ca435 100644
> +--- a/Modules/main.c
> ++++ b/Modules/main.c
> +@@ -1857,6 +1857,11 @@ config_init_home(_PyCoreConfig *config)
> +     }
> + 
> +     int res = config_get_env_var_dup(&home, L"PYTHONHOME", "PYTHONHOME");
> ++
> ++    const char *oepython3home = config_get_env_var("OEPYTHON3HOME");
> ++    if (oepython3home) {
> ++        res = config_get_env_var_dup(&home, L"OEPYTHON3HOME", "OEPYTHON3HOME");
> ++    }
> +     if (res < 0) {
> +         return DECODE_LOCALE_ERR("PYTHONHOME", res);
> +     }
> +-- 
> +2.7.4

I think the above will leak memory.

Instead I think the code should be something like:

int res;
const char *oepython3home = config_get_env_var("OEPYTHON3HOME");
if (oepython3home) {
    res = config_get_env_var_dup(&home, L"OEPYTHON3HOME", "OEPYTHON3HOME");
    if (res < 0)
        return DECODE_LOCALE_ERR("OEPYTHON3HOME", res);
} else {
    res = config_get_env_var_dup(&home, L"PYTHONHOME", "PYTHONHOME");
    if (res < 0)
        return DECODE_LOCALE_ERR("PYTHONHOME", res);
}

and then a copy of PYTHONHOME isn't created in the OEPYTHON3HOME case.

Cheers,

Richard



  reply	other threads:[~2019-04-25 20:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25 19:56 [master][RFC] Adding back wrapper and using OEPYTHON3HOME variable for python3 Jaewon Lee
2019-04-25 20:50 ` richard.purdie [this message]
2019-04-25 21:59   ` Jaewon Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=72e102b7e2a14c0747e3b485a6429f8dde546508.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=alejandr@xilinx.com \
    --cc=jaewon.lee@xilinx.com \
    --cc=manjukum@xilinx.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.