Mailinglist Archive: opensuse-programming (96 mails)
| < Previous | Next > |
Re: [suse-programming-e] Pointer strangeness
- From: Jerry Feldman <gfeldman@xxxxxxxxx>
- Date: Mon, 31 Mar 2003 12:38:55 -0500
- Message-id: <20030331123855.5a1b586a.gfeldman@xxxxxxxxx>
On Mon, 31 Mar 2003 10:08:33 -0500 (EST)
"Steven T. Hatton" <hattons@xxxxxxxxxxxxxxxxxx> wrote:
> Ok, now I see what's going on. My pointing to temp with memberIntPtr
> doesn't place a 'handle' on so when temp is gone, that memory is up
> for grabs
As I said, tmp is allocated on the stack. When the function returns, the
stack is unwound and then used by another function.
char *s = "abcd" + 2;
For your own edification, try explaining this. This a perfectly legal
thing to do. A friend used to ask this as an interview question.
--
Jerry Feldman <gaf@xxxxxxx>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
"Steven T. Hatton" <hattons@xxxxxxxxxxxxxxxxxx> wrote:
> Ok, now I see what's going on. My pointing to temp with memberIntPtr
> doesn't place a 'handle' on so when temp is gone, that memory is up
> for grabs
As I said, tmp is allocated on the stack. When the function returns, the
stack is unwound and then used by another function.
char *s = "abcd" + 2;
For your own edification, try explaining this. This a perfectly legal
thing to do. A friend used to ask this as an interview question.
--
Jerry Feldman <gaf@xxxxxxx>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
| < Previous | Next > |