Mail Archives: djgpp-workers/2003/01/05/11:41:00
According to Richard Dawe:
> > > > + v_printf("Using " MINSTACK_ENV_VAR " = %s.\n", env_stack_size);
> > > > +
> > > > + stubedit_str = malloc( sizeof("stubify ")+strlen(ofilename)+sizeof(" minstack=")+strlen(env_stack_size)+1 );
> > >
> > > Why do you do sizeof("stubify ")? Shouldn't it be strlen? And on "stubedit "?
> > > I.e.: strlen("stubedit ")? As it turns out, the number from the above code is
> > > right.
> >
> > As strlen("some string") == sizeof("some string") in C, that shouldn't
> > be a surprise. It's for removing an unnecessary function call when we
> > can calculate it statically.
>
> OK, but shouldn't it be sizeof("stubedit "), since that's what gets written
Oops! Yes, thanks!
> into the string? You could also remove the "+1" at the end, since sizeof will
> include the nul terminator.
Oink! I see. I was wrong after all: strlen("some string") ==
sizeof("some string") - 1. I didn't think of that. The only positive
thing is that I erred(sp?) towards safety...
> How about:
>
> fprintf(stderr, "%s: illegal minimum stack size specified in environment
> variable " MINSTACK_ENV_VAR ": %s\n", ofilename, env_stack_size);
Great. Incorporated.
Right,
MartinS
- Raw text -