John Summerfield writes:
If you mean something different from all of these, please clarify.
It seems likely that cfgfile is a per-user configuration file for an
application. If so, HOME=/ should be treated as a error.
--
John Hasler
[EMAIL PROTECTED]
Dancing Horse Hill
Elmwood, Wisconsin
--
On Thu, Aug 12, 2004 at 10:59:36AM +0800, John Summerfield wrote:
So set the ball rolling, here is a snippet from a program I found via
freshmeat the other day:
configfile = malloc(strlen(getenv(HOME)) + 20);
sprintf(configfile,%s/%s,getenv(HOME), cfgfile);
Something a bit
On Thu, Aug 12, 2004 at 04:38:25PM -0400, Jason Rennie wrote:
Something a bit safer...
char *home = getenv(HOME);
if (home == NULL || cfgfile == NULL) hittheuseronthehead();
int sz = strlen(home) + strlen(cfgfile) + 2;
char *configfile = malloc(sizeof(char)*sz);
Jason Rennie wrote:
On Thu, Aug 12, 2004 at 10:59:36AM +0800, John Summerfield wrote:
So set the ball rolling, here is a snippet from a program I found via
freshmeat the other day:
configfile = malloc(strlen(getenv(HOME)) + 20);
sprintf(configfile,%s/%s,getenv(HOME), cfgfile);
Something
On Thursday 12 August 2004 15:38, Jason Rennie wrote:
Something a bit safer...
char *home = getenv(HOME);
if (home == NULL || cfgfile == NULL) hittheuseronthehead();
int sz = strlen(home) + strlen(cfgfile) + 2;
char *configfile = malloc(sizeof(char)*sz);
John Summerfield wrote:
Jason Rennie wrote:
On Thu, Aug 12, 2004 at 10:59:36AM +0800, John Summerfield wrote:
So set the ball rolling, here is a snippet from a program I found via
freshmeat the other day:
configfile = malloc(strlen(getenv(HOME)) + 20);
On Thu, Aug 12, 2004 at 01:51:46PM -0700, Stefan Nicolai O'Rear wrote:
Using a glibc extension, how about:
char *configfile;
asprintf (configfile, %s/%s, getenv (HOME), cfgfile);
aprintf auto-mallocs a buffer of the right size.
Be sure to free()!
On Thu, Aug 12, 2004 at 04:22:46PM
John Summerfield wrote:
So set the ball rolling, here is a snippet from a program I found via
freshmeat the other day:
configfile = malloc(strlen(getenv(HOME)) + 20);
sprintf(configfile,%s/%s,getenv(HOME), cfgfile);
The malloc() might fail and return NULL. You need to deal with
John Hasler wrote:
John Summerfield wrote:
So set the ball rolling, here is a snippet from a program I found via
freshmeat the other day:
configfile = malloc(strlen(getenv(HOME)) + 20);
sprintf(configfile,%s/%s,getenv(HOME), cfgfile);
The malloc() might fail and return NULL. You need
John Summerfield writes:
The size of cfgfile is what bothered me as soon as I saw it.Presumably
properly calculating the amount of storage to request takes care of that.
As I said: use snprintf or do something else. In fact, use snprintf
anyway.
Leading / is fine...
We don't have the rest
John Hasler wrote:
John Summerfield writes:
The size of cfgfile is what bothered me as soon as I saw it.Presumably
properly calculating the amount of storage to request takes care of that.
As I said: use snprintf or do something else. In fact, use snprintf
anyway.
Leading / is fine...
On Thu, Aug 12, 2004 at 07:28:24PM -0500, John Hasler wrote:
The malloc() might fail and return NULL. You need to deal with that.
Good point. Can't believe I missed that...
Jason
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL
I found this interesting article:
http://www.osnews.com/story.php?news_id=7990
As I have a pretty clear view of my limitations as a C coder I thought
I'd take a look.
See how you score on the examples here:
http://www.nostarch.com/frameset.php?startat=hownotc
So set the ball rolling, here is a
On Thu, Aug 12, 2004 at 10:59:36AM +0800, John Summerfield wrote:
I found this interesting article:
http://www.osnews.com/story.php?news_id=7990
As I have a pretty clear view of my limitations as a C coder I thought
I'd take a look.
See how you score on the examples here:
On Wed, Aug 11, 2004 at 08:23:21PM -0700, William Ballard wrote:
On Thu, Aug 12, 2004 at 10:59:36AM +0800, John Summerfield wrote:
configfile = malloc(strlen(getenv(HOME)) + 20);
sprintf(configfile,%s/%s,getenv(HOME), cfgfile);
The length of HOME could increase between invocations.
William Ballard wrote:
So set the ball rolling, here is a snippet from a program I found via
freshmeat the other day:
configfile = malloc(strlen(getenv(HOME)) + 20);
sprintf(configfile,%s/%s,getenv(HOME), cfgfile);
The length of HOME could increase between invocations. I don't fancy
16 matches
Mail list logo