Unix Technical Forum

Code-Cleanup: char* -> const char*

This is a discussion on Code-Cleanup: char* -> const char* within the Pgsql Patches forums, part of the PostgreSQL category; --> Hi, attached patches marks several char* variables as const where they are initialized with constant strings. Regards, Stefan ---------------------------(end ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 09:42 AM
Stefan Huehner
 
Posts: n/a
Default Code-Cleanup: char* -> const char*

Hi,

attached patches marks several char* variables as const where they are
initialized with constant strings.

Regards,
Stefan



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 09:43 AM
Neil Conway
 
Posts: n/a
Default Re: Code-Cleanup: char* -> const char*

Stefan Huehner wrote:
> attached patches marks several char* variables as const where they are
> initialized with constant strings.
>


I really wonder how much value there is in using the "const" modifier
very widely. "const" for function parameters is valuable (because it
adds information about the function's behavior to its interface). It
also makes sense to use "const" on global variables, when it reduces the
size of the binary's data segment. Beyond that, you reach the point of
diminishing returns fairly quickly, IMHO. (In C, anyway; it makes more
sense to use it widely in C++, of course.)

I also don't see the value in modifying the regexp code, as that is just
an import of Henry Spencer's regexp package. I'm not sure whether we're
planning on merging any upstream changes any time soon, but making
cosmetic changes to the RE code will only make that more difficult.

Anyway, I'll apply this tomorrow without the RE changes, barring any
objections.

BTW, the preferred format for patches is context diffs, not unified diffs.

-Neil


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 09:43 AM
Tom Lane
 
Posts: n/a
Default Re: Code-Cleanup: char* -> const char*

Neil Conway <neilc@samurai.com> writes:
> I also don't see the value in modifying the regexp code, as that is just
> an import of Henry Spencer's regexp package.


The same objection applies to most of the proposed changes in /src/port/
since those are generally imports from BSD libc code. I don't mind
cosmetic changes in files that are actually homegrown, but for imported
files it's probably best to avoid unnecessary delta from upstream.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-18-2008, 09:43 AM
Bruce Momjian
 
Posts: n/a
Default Re: Code-Cleanup: char* -> const char*

Neil Conway wrote:
> BTW, the preferred format for patches is context diffs, not unified diffs.


FYI, for the type of diff he is supplying unified diffs are better
because it is single-line changes, and you see the old/new lines next to
each other; the developer's FAQ mentions this.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:03 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com