Eli Za=
retskii <
eliz@gnu.org> schrieb am=
So., 22. Nov. 2015 um 17:56=C2=A0Uhr:
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sun, 22 Nov 2015 16:27:19 +0000
> Cc: eggert@cs.=
ucla.edu, aurelien.aptel+emacs@gmail.com, tzz@lifelogs.com,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0emacs-devel@gnu.org
>
> Eli Zaretskii <el=
iz@gnu.org> schrieb am So., 22. Nov. 2015 um 17:23 Uhr:
>
>=C2=A0 =C2=A0 =C2=A0I don't understand: we already have in emacs-mo=
dule.c machinery that
>=C2=A0 =C2=A0 =C2=A0handles non-local exits. Why cannot xmalloc do the =
same when it's
>=C2=A0 =C2=A0 =C2=A0called from emacs-module.c?
>
> My impression was that Paul talked about code in modules, not code in<=
br>
> emacs-module.c. The latter can use xmalloc just fine, if appropriate p=
rotection
> is installed first.
I'll let Paul explain what he was worried about.=C2=A0 What I was worri=
ed
about is that memory allocation done by emacs-module.c on behalf of
modules doesn't behave like xmalloc does, doesn't comply to the
MALLOC_BLOCK_INPUT protocol, and cannot be probed by MALLOC_PROBE.=C2=A0 I<=
br>
think this should be easy to fix.
Yes, I've attached a patch.=C2=A0<=
/div>
--047d7b5d382cdb728e0525244bf8--
--047d7b5d382cdb72940525244bfa
Content-Type: application/octet-stream;
name="0001-Use-xmalloc-in-module-code.patch"
Content-Disposition: attachment;
filename="0001-Use-xmalloc-in-module-code.patch"
Content-Transfer-Encoding: base64
Content-ID: <1513033ff78fadbb99f1>
X-Attachment-Id: 1513033ff78fadbb99f1
RnJvbSAxNTExZmFiOTczZDBjMDU0ZjQyNzlmODU3NDEyYWUwZjNkZWUyOGFlIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBQaGlsaXBwIFN0ZXBoYW5pIDxwaHN0QGdvb2dsZS5jb20+CkRh
dGU6IFN1biwgMjIgTm92IDIwMTUgMTg6MTQ6MjIgKzAxMDAKU3ViamVjdDogW1B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