On Tuesday 03 December 2024 16:33:01 Martin Storsjö wrote:
> On Wed, 27 Nov 2024, Pali Rohár wrote:
> 
> > Variable startinfo is used only by __(w)getmainargs() call passed by the
> > pointer in pre_cpp_init() function. The __(w)getmainargs() function does
> > not use or store the pointer value, so the variable does not have to be
> > static. Declare this variable just on the pre_cpp_init() function stack.
> > ---
> > mingw-w64-crt/crt/crtexe.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
> > index 2c6fbd7e7062..319cace6f50a 100644
> > --- a/mingw-w64-crt/crt/crtexe.c
> > +++ b/mingw-w64-crt/crt/crtexe.c
> > @@ -62,7 +62,6 @@ static int argret;
> > static int mainret=0;
> > static int managedapp;
> > static int has_cctor = 0;
> > -static _startupinfo startinfo;
> > extern LPTOP_LEVEL_EXCEPTION_FILTER __mingw_oldexcpt_handler;
> > 
> > extern void _pei386_runtime_relocator (void);
> > @@ -125,6 +124,8 @@ pre_c_init (void)
> > static void __cdecl
> > pre_cpp_init (void)
> > {
> > +  _startupinfo startinfo;
> > +
> >   startinfo.newmode = _newmode;
> 
> This looks ok - but do you happen to know any further about what
> __getmainargs or __wgetmainargs do with this struct? Is it only used for
> passing settings into those functions, or do they return data in it as well
> (which we don't seem to use anyway)?
> 
> // Martin

It is input-only read-only structure. No pointer to the structure is
used after the end of the function. Moreover structure has only one
member, _newmode. So from ABI perspective, it is same as passing the
pointer to the _newmode (first and only member of the structure).


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to