* a question about script_setenv in main.c for pppd code
@ 2008-07-15 9:22 c4linux
2008-07-15 15:28 ` James Carlson
0 siblings, 1 reply; 2+ messages in thread
From: c4linux @ 2008-07-15 9:22 UTC (permalink / raw)
To: linux-ppp
Hi,all:
In main.c:
void
script_setenv(var, value, iskey)
char *var, *value;
int iskey;
{
size_t varl = strlen(var);
size_t vl = varl + strlen(value) + 2;
int i;
char *p, *newstring;
newstring = (char *) malloc(vl+1);
if (newstring = 0)
return;
*newstring++ = iskey;
slprintf(newstring, vl, "%s=%s", var, value);
/* check if this variable is already set */
if (script_env != 0) {
for (i = 0; (p = script_env[i]) != 0; ++i) {
if (strncmp(p, var, varl) = 0 && p[varl] = '=') {
#ifdef USE_TDB
if (p[-1] && pppdb != NULL)
delete_db_key(p);
#endif
free(p-1);
......
......
why not free(p) but free(p-1) ?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: a question about script_setenv in main.c for pppd code
2008-07-15 9:22 a question about script_setenv in main.c for pppd code c4linux
@ 2008-07-15 15:28 ` James Carlson
0 siblings, 0 replies; 2+ messages in thread
From: James Carlson @ 2008-07-15 15:28 UTC (permalink / raw)
To: linux-ppp
c4linux writes:
> /* check if this variable is already set */
> if (script_env != 0) {
> for (i = 0; (p = script_env[i]) != 0; ++i) {
> if (strncmp(p, var, varl) = 0 && p[varl] = '=') {
> #ifdef USE_TDB
> if (p[-1] && pppdb != NULL)
> delete_db_key(p);
> #endif
> free(p-1);
> ......
> ......
>
> why not free(p) but free(p-1) ?
It's because of these two lines in that same function:
*newstring++ = iskey;
[...]
script_env[i] = newstring;
--
James Carlson 42.703N 71.076W <carlsonj@workingcode.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-07-15 15:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-15 9:22 a question about script_setenv in main.c for pppd code c4linux
2008-07-15 15:28 ` James Carlson
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.