> > From: arthur miller <arthur.miller@live.com>
> > CC: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
> > Date: Fri, 3 Jan 2025 00:24:58 +0000
> >
> > (let ((cp (w32-get-console-codepage))
> >       (cpo (w32-get-console-output-codepage)))
> >   (dotimes (i 100000)
> >     (w32-set-console-codepage i)
> >     (w32-set-console-output-codepage i)
> >     (w32-set-console-codepage (- i 10000))
> >     (w32-set-console-output-codepage (- i 10000)))
> >   (w32-set-console-codepage cp)
> >   (w32-set-console-output-codepage cpo))
> >
> > Anyway, in the world of utf8 I guess nobody is using that code anyway,
> > so it does not really matter. Was just a little curiosa while I was
> > looking through the code for the reference.
>
> The codepages are still very much used in Emacs on Windows.  The
> Windows UTF-8 support is rudimentary and marked "experimental" by MS.
> So we still need to consider the codepages when referencing external
> stuff.

Ok; thnks. I thought Emacs was doing its own coding/decoding, but I am
not yet familiar with that stuff. I guess I'll have more questions about
that stuff.

> > >> I don't see any usage of this function, neither in C code nor
> > >> in Lisp (I grepped through); so I guess it is just eventually only called from
> > >> the external packages or just interactively by the user. Is it worth to copy
> > >> the returned list into a local list and return that so that the global list can
> > >> be freed so not to leak that list in the case the user does not want to save
> > >> that list anyway?
> > >
> > >I don't understand where did you see a leak, and what kind of a leak
> > >is that, please elaborate.
> >
> > I am assuming that this function can't be used very often. If the user
> > calls it for some reason (debugging, curiosity, checking if a codepage
> > is loaded?), the list will be constructed, but probably not used in a
> > single usage. But the space allocated for it will be allocated until
> > Emacs exists. If space is used but not needed than in a sense, it is a
> > memory leak.
>
> That's not a memory leak in my book, no.  A value that is computed
> once and left to be used for the entire session is not a leak.

Mnjah; of course, I don't know why this particular function was
implemented, but my guess is debugging or just a simple check if a page
is loaded or something? I would guess the usage is rather temporary in a
single place or just occasionally. If some user could have a reason to
save it for the entire duration of an Emacs session they could save it
in a lisp variable themselves. As now, since there is a global
reference protected from GC, in the most probable case, the list will be
left alive for the life of the session, even if they don't use it.

Anyway, thanks for the explanations.