[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
valid_pointer_p
From: |
Eli Zaretskii |
Subject: |
valid_pointer_p |
Date: |
Sat, 29 Jul 2006 13:27:07 +0300 |
Can someone ``in the know'' please explain what clever idea is behind
the function valid_pointer_p, and whether that idea is supposed to be
portable? This function was previously used only if !GC_MARK_STACK,
but now its use was extended to all configurations, so I think at the
very least its commentary should be expanded and clarified, even if it
turns out that its method is universally right.
Here's the code of the function, for your convenience:
/* Determine whether it is safe to access memory at address P. */
int
valid_pointer_p (p)
void *p;
{
int fd;
/* Obviously, we cannot just access it (we would SEGV trying), so we
trick the o/s to tell us whether p is a valid pointer.
Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may
not validate p in that case. */
if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY |
O_TRUNC, 0666)) >= 0)
{
int valid = (emacs_write (fd, (char *)p, 16) == 16);
emacs_close (fd);
unlink ("__Valid__Lisp__Object__");
return valid;
}
return -1;
}
- valid_pointer_p,
Eli Zaretskii <=
- Re: valid_pointer_p, Andreas Schwab, 2006/07/29
- Re: valid_pointer_p, Kim F. Storm, 2006/07/29
- Re: valid_pointer_p, Eli Zaretskii, 2006/07/29
- Re: valid_pointer_p, Kim F. Storm, 2006/07/30
- Re: valid_pointer_p, Eli Zaretskii, 2006/07/30
- Re: valid_pointer_p, Andreas Schwab, 2006/07/31
- Re: valid_pointer_p, Eli Zaretskii, 2006/07/31
- Re: valid_pointer_p, Andreas Schwab, 2006/07/31
- Re: valid_pointer_p, Kim F. Storm, 2006/07/31