[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hash-table-{to, from}-alist
From: |
Andreas Schwab |
Subject: |
Re: hash-table-{to, from}-alist |
Date: |
Tue, 02 Dec 2008 22:27:37 +0100 |
User-agent: |
Gnus/5.110009 (No Gnus v0.9) Emacs/22.3 (gnu/linux) |
Ted Zlatanov <address@hidden> writes:
> I ended up with this code to put a list into Fmake_hash_table format
> ('params' is a Lisp_Object that holds a bunch of conses).
>
> int param_count = 0;
> Lisp_Object *pa = (Lisp_Object*)
> xmalloc(XFASTINT(Flength(params)) * sizeof(Lisp_Object));
>
> while (!NILP(params))
> {
> pa[param_count++] = CAR_SAFE(params);
> params = CDR_SAFE(params);
> }
>
> Lisp_Object ht = Fmake_hash_table(param_count, pa);
This is of course a memory leak, since pa is never freed.
> I would prefer it if I could avoid all that work, but it seems (from
> reading lisp.h and hunting for similar code) that it must be done as
> above. I don't see a macro to convert a Lisp_Object that holds a list
> into the Lisp_Object* that a lot of functions need.
Since you know the max size of the array, just declare it as such.
(One more reason to implement it in Lisp.)
Andreas.
--
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
- Re: hash-table-{to, from}-alist, (continued)
Re: hash-table-{to, from}-alist, Stefan Monnier, 2008/12/02
Re: hash-table-{to, from}-alist, Ted Zlatanov, 2008/12/01
Re: hash-table-{to, from}-alist, Ted Zlatanov, 2008/12/02
- Re: hash-table-{to, from}-alist,
Andreas Schwab <=
Re: hash-table-{to, from}-alist, Stefan Monnier, 2008/12/02
- Re: hash-table-{to, from}-alist, Ted Zlatanov, 2008/12/03
- Re: hash-table-{to, from}-alist, Stefan Monnier, 2008/12/03
- Re: hash-table-{to, from}-alist, Stephen J. Turnbull, 2008/12/04
- Re: hash-table-{to, from}-alist, Miles Bader, 2008/12/04
- Re: hash-table-{to, from}-alist, Andreas Schwab, 2008/12/04
- Re: hash-table-{to, from}-alist, Stefan Monnier, 2008/12/04
Re: hash-table-{to, from}-alist, Ted Zlatanov, 2008/12/04
Re: hash-table-{to, from}-alist, Stefan Monnier, 2008/12/04
Re: hash-table-{to, from}-alist, Ted Zlatanov, 2008/12/04