From: Nguyen Thai Ngoc Duy Date: Fri, 18 Mar 2011 10:34:07 GMT Subject: Re: [PATCH] system_path: use a static buffer Message-ID: In-Reply-To: <1300371853-8965-1-git-send-email-cmn@elego.de> On Thu, Mar 17, 2011 at 9:24 PM, Carlos Martín Nieto wrote: > -       static const char *system_wide; > -       if (!system_wide) > -               system_wide = system_path(ETC_GITATTRIBUTES); > +       static char system_wide[PATH_MAX]; ... > -       static const char *system_wide; > -       if (!system_wide) > -               system_wide = system_path(ETC_GITCONFIG); > +       static char system_wide[PATH_MAX]; ... >  #ifdef RUNTIME_PREFIX > -       static const char *prefix; > +       static const char *prefix = NULL; >  #else >        static const char *prefix = PREFIX; >  #endif > -       struct strbuf d = STRBUF_INIT; > +       static char buf[PATH_MAX]; > +       int ret; It was pointed out elsewhere [1] that PATH_MAX only specifies max length of a path element, not full path. I think we'd need to stay away from preallocated PATH_MAX-sized arrays. [1] http://mid.gmane.org/AANLkTikXvx7-Q8B_dqG5mMHGK_Rw-dFaeQdXi0zW98SD@mail.gmail.com -- Duy