All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Riedy <ejr@EECS.Berkeley.EDU>
To: Timo Hirvonen <tihirvon@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Use setenv(), fix warnings
Date: Sun, 26 Feb 2006 11:38:30 -0800	[thread overview]
Message-ID: <15703.1140982710@lotus.CS.Berkeley.EDU> (raw)
In-Reply-To: <20060226203756.05dcfb26.tihirvon@gmail.com>

And Timo Hirvonen writes:
 - It appears that statically allocated strings are accepted but 
 - _automatic_ variables aren't.

The putenv()-ed string has to exist as long as the environment
does.  You can twiddle the environment just by twiddling the
string you registered.  What fun!

 - I noticed setenv is now in compat/ so I though it was good idea
 - to use it.

All uses of putenv() originally were setenv().  I finally realized
a compat/setenv.c was better than playing whack-a-setenv on every
release...  (Ah, hindsight.)

Note that the current compat/setenv.c _LEAKS MEMORY_ on purpose.  
Because putenv() requires the string to stay around, we can't
ever free it.  I hope any library implementing bits of git
(libgitbit?) avoids setting environment variables.

 - So the variable is emptied, not removed.  But usually empty environment
 - variables are treated as if they didn't exist...

More specifically, git treats both "" and NULL as empty, or at 
least it did last time I checked.

Jason

  reply	other threads:[~2006-02-26 19:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-26 15:13 [PATCH] Use setenv(), fix warnings Timo Hirvonen
2006-02-26 18:06 ` Junio C Hamano
2006-02-26 18:37   ` Timo Hirvonen
2006-02-26 19:38     ` Jason Riedy [this message]
2006-02-26 20:29     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15703.1140982710@lotus.CS.Berkeley.EDU \
    --to=ejr@eecs.berkeley.edu \
    --cc=git@vger.kernel.org \
    --cc=tihirvon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.