This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: expose creating windows-style envblock from current environment


On Oct 23 18:08, Yitzchak Scott-Thoennes wrote:
> I need to translate the current environment in a cygwin C program to
> an envblock suitable for calling CreateProcess directly, and couldn't
> think of a better way than the following patch.

I'm wondering why that's necessary at all.  You have access to the app's
POSIX environment and you know by a simple look into Cygwin which
variables have to be path converted and which not.  That can be done
using cygwin_conv_to_win32_path/cygwin_posix_to_win32_path_list.  Looks
like a task easily accomplished inside of the application.

> But I think there's something I'm not understanding; with the free()
> calls in place, it coredumps, though checking the code in environ.cc
> seems to show that all the freed chunks should have been properly
> allocated.

envp and the envp members are allocated on the cygheap using cmalloc()
and cstrdup() so you must free them with cfree().

> As an aside, does the build_env call in spawn.cc leak?

How?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat, Inc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]