[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: libnettle/libhogweed WIP
From: |
Eli Zaretskii |
Subject: |
Re: libnettle/libhogweed WIP |
Date: |
Mon, 17 Apr 2017 20:11:32 +0300 |
> From: Ted Zlatanov <address@hidden>
> Date: Mon, 17 Apr 2017 12:55:32 -0400
>
> EZ> Why not use my suggestion, producing a Lisp string out of C string
> EZ> just before returning?
>
> I don't see the difference between allocating a C string +
> make_unibyte_string(), and doing
>
> Lisp_Object storage = make_uninit_string (storage_length);
> ...
> return make_unibyte_string (SSDATA (storage), storage_length);
It's a minor issue, admittedly. make_unibyte_string allocates a Lisp
string, which does more than just allocate the string data (e.g., Lisp
memory allocation is non-reentrant, so it calls block_input). It also
requires allocation whose alignment is potentially more stringent than
simple C memory allocation, certainly so if SAFE_ALLOCA decides to use
alloca, not malloc, so it slightly increases memory pressure.
IOW, it's a kind of aesthetic issue: code that allocates a Lisp string
just so it could use its data as storage, and then actually makes a
different string to return to the caller, looks less elegant to me.
> because either way the data has to be copied, and the latter needs less
> care with freeing the memory.
Using SAFE_ALLOCA is not complicated, either.
> It's really not a big deal to switch to your suggestion, I just
> don't know why it matters?
I hope the above explains why.
- Re: libnettle/libhogweed WIP, (continued)
- Re: libnettle/libhogweed WIP, Ted Zlatanov, 2017/04/14
- Re: libnettle/libhogweed WIP, Eli Zaretskii, 2017/04/15
- Re: libnettle/libhogweed WIP, Ted Zlatanov, 2017/04/15
- Re: libnettle/libhogweed WIP, Eli Zaretskii, 2017/04/15
- Re: libnettle/libhogweed WIP, Ted Zlatanov, 2017/04/15
- Re: libnettle/libhogweed WIP, Eli Zaretskii, 2017/04/16
- Re: libnettle/libhogweed WIP, Eli Zaretskii, 2017/04/16
- Re: libnettle/libhogweed WIP, Ted Zlatanov, 2017/04/17
- Re: libnettle/libhogweed WIP, Eli Zaretskii, 2017/04/17
- Re: libnettle/libhogweed WIP, Ted Zlatanov, 2017/04/17
- Re: libnettle/libhogweed WIP,
Eli Zaretskii <=
- Re: libnettle/libhogweed WIP, Ted Zlatanov, 2017/04/17
- Re: libnettle/libhogweed WIP, Eli Zaretskii, 2017/04/17
- Re: libnettle/libhogweed WIP, Ted Zlatanov, 2017/04/17
- Re: libnettle/libhogweed WIP, Ted Zlatanov, 2017/04/17
- Re: libnettle/libhogweed WIP, Noam Postavsky, 2017/04/17
- Re: libnettle/libhogweed WIP, Ted Zlatanov, 2017/04/17
- Re: libnettle/libhogweed WIP, Ted Zlatanov, 2017/04/18
- Re: libnettle/libhogweed WIP, Noam Postavsky, 2017/04/18
- Re: libnettle/libhogweed WIP, Davis Herring, 2017/04/19
- Re: libnettle/libhogweed WIP, Eli Zaretskii, 2017/04/19