Hi Richard,

Agreed, will send a v2

Thanks,
Jaewon

-----Original Message-----
From: richard.pur...@linuxfoundation.org <richard.pur...@linuxfoundation.org> 
Sent: Thursday, April 25, 2019 1:50 PM
To: Jaewon Lee <jae...@xilinx.com>; openembedded-core@lists.openembedded.org; 
Manjukumar Harthikote Matha <manju...@xilinx.com>; Alejandro Enedino Hernandez 
Samaniego <aleja...@xilinx.com>
Subject: Re: [OE-core][master][RFC] Adding back wrapper and using OEPYTHON3HOME 
variable for python3

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

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to