FreeBSD/sys/kern/kern_environment.c
/*
 * Unset an environment variable string.
 */
Unset an environment variable string.
Unset an environment variable string .
int
kern_unsetenv(const char *name)
{
	char *cp, *oldenv;
	int i, j;
	KENV_CHECK;
	mtx_lock(&kenv_lock);
	cp = _getenv_dynamic(name, &i);
	if (cp != NULL) {
		oldenv = kenvp[i];
		for (j = i + 1; kenvp[j] != NULL; j++)
			kenvp[i++] = kenvp[j];
		kenvp[i] = NULL;
		mtx_unlock(&kenv_lock);
		memset(oldenv, 0, strlen(oldenv));
		free(oldenv, M_KENV);
		return (0);
	}
	mtx_unlock(&kenv_lock);
	return (-1);
}
int kern_unsetenv ( const char * name ) { char * cp , * oldenv ; int i , j ; KENV_CHECK ; mtx_lock ( & kenv_lock ) ; cp = _getenv_dynamic ( name , & i ) ; if ( cp != NULL ) { oldenv = kenvp [ i ] ; for ( j = i + 1 ; kenvp [ j ] != NULL ; j ++ ) kenvp [ i ++ ] = kenvp [ j ] ; kenvp [ i ] = NULL ; mtx_unlock ( & kenv_lock ) ; memset ( oldenv , 0 , strlen ( oldenv ) ) ; free ( oldenv , M_KENV ) ; return ( 0 ) ; } mtx_unlock ( & kenv_lock ) ; return ( -1 ) ; }
Unset an environment variable string.
Unset an environment variable string .