MCPcopy Create free account
hub / github.com/F-Stack/f-stack / kern_unsetenv

Function kern_unsetenv

freebsd/kern/kern_environment.c:597–618  ·  view source on GitHub ↗

* Unset an environment variable string. */

Source from the content-addressed store, hash-verified

595 * Unset an environment variable string.
596 */
597int
598kern_unsetenv(const char *name)
599{
600 char *cp, *oldenv;
601 int i, j;
602
603 KENV_CHECK;
604
605 mtx_lock(&kenv_lock);
606 cp = _getenv_dynamic(name, &i);
607 if (cp != NULL) {
608 oldenv = kenvp[i];
609 for (j = i + 1; kenvp[j] != NULL; j++)
610 kenvp[i++] = kenvp[j];
611 kenvp[i] = NULL;
612 mtx_unlock(&kenv_lock);
613 zfree(oldenv, M_KENV);
614 return (0);
615 }
616 mtx_unlock(&kenv_lock);
617 return (-1);
618}
619
620/*
621 * Return the internal kenv buffer for the variable name, if it exists.

Callers 3

resource_unset_valueFunction · 0.85
sys_kenvFunction · 0.85
start_initFunction · 0.85

Calls 4

mtx_lockFunction · 0.70
_getenv_dynamicFunction · 0.70
mtx_unlockFunction · 0.70
zfreeFunction · 0.70

Tested by

no test coverage detected