From: | Mike Mascari <mascarim(at)yahoo(dot)com> |
---|---|
To: | Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [HACKERS] What is nameout() for? |
Date: | 1999-11-07 20:38:34 |
Message-ID: | 19991107203834.21729.rocketmail@web2105.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
--- Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> wrote:
> I am confused by nameout(). There are a number of places where table
> names are output using nameout(), and many other cases where they are
> just output without calling nameout. Can someone explain why the dash
> is important? I can see the pstrdup as being important, but not in all
> of the cases where nameout is called.
>
>
---------------------------------------------------------------------------
>
> /*
> * nameout - converts internal reprsentation to "..."
> */
> char *
> nameout(NameData *s)
> {
> if (s == NULL)
> return "-";
> else
> return pstrdup(s->data);
> }
>
Actually, I have 'C' question regarding the above code. Where does the
"-" live in RAM? Does the compiler generated a data hunk such that this
string will be apart of the final executable and each invocation of this
routine would result in a pointer to that 'global' location being
returned?
Or does it allocate the memory for, and initialize, the "-" on the stack?
If so, isn't returning a "-" a dangerous act?
In fact, isn't returning a "-" dangerous either way without the
protoype being:
const char *nameout(NameData *s);
^^^^^
Sorry to drift off topice, but I was just curious,
Mike Mascari
(mascarim(at)yahoo(dot)com)
=====
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Don Baccus | 1999-11-07 20:47:51 | Re: [HACKERS] What is nameout() for? |
Previous Message | Brian Hirt | 1999-11-07 19:39:13 | Re: [HACKERS] IN clause and INTERSECT not behaving as expected |