Re: [HACKERS] What is nameout() for?

Поиск
Список
Период
Сортировка
От Mike Mascari
Тема Re: [HACKERS] What is nameout() for?
Дата
Msg-id 19991107203834.21729.rocketmail@web2105.mail.yahoo.com
обсуждение исходный текст
Ответы Re: [HACKERS] What is nameout() for?  (Don Baccus <dhogaza@pacifier.com>)
Re: [HACKERS] What is nameout() for?  (Bruce Momjian <maillist@candle.pha.pa.us>)
Re: [HACKERS] What is nameout() for?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
--- Bruce Momjian <maillist@candle.pha.pa.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@yahoo.com)





=====

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Brian Hirt
Дата:
Сообщение: Re: [HACKERS] IN clause and INTERSECT not behaving as expected
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] What is nameout() for?