emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sorting in C


From: Andrew Cohen
Subject: Re: sorting in C
Date: Sun, 27 Feb 2022 18:42:11 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>>>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:

[...]

    >> When I need new memory I call
    >> 
    >> : specpdl_ref sa_count = SPECPDL_INDEX (); : a = (Lisp_Object *)
    >> record_xmalloc (need * sizeof (Lisp_Object));
    >> 
    >> and I save =sa_count=; I guess =record_xmalloc= handles freeing
    >> the memory on exception. Later during the sorting process I free
    >> the memory explicitly with
    >> 
    >> : safe_free (sa_count)
    >> 
    >> Does this seem right? (Probably, since I've been running this way
    >> for awhile and would have expected lots of problems if I weren't
    >> allocating and freeing the memory :))

    EZ> I'd rather you didn't use safe_free, since that is for
    EZ> SAFE_ALLOCA etc.  Just use unbind_to directly, like we do
    EZ> elsewhere where record_xmalloc is used.

Ahh, didn't know about that function. I replaced the safe_free with
unbind_to and seems to work fine.

Thanks,
Andy

-- 
Andrew Cohen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]