1 /* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
2 * This file is part of the Linux-8086 C library and is distributed
3 * under the GNU Library General Public License.
9 extern char ** environ
;
16 static char ** mall_env
= 0;
17 static int extras
= 0;
23 if( r
== 0 ) len
= strlen(var
);
26 for(p
=environ
; *p
; p
++)
28 if( memcmp(var
, *p
, len
) == 0 && (*p
)[len
] == '=' )
30 while( p
[0] = p
[1] ) p
++;
35 if( r
== 0 ) return 0;
36 if( extras
<= 0 ) /* Need more space */
38 d
= malloc((p
-environ
+1+ADD_NUM
)*sizeof(char*));
39 if( d
== 0 ) return -1;
41 memcpy((void*) d
, (void*) environ
, (p
-environ
+1)*sizeof(char*));
45 if( mall_env
) free(mall_env
);