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?
Re: [HACKERS] What is nameout() for? Re: [HACKERS] What is nameout() for? |
Список | 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 по дате отправления: