MCPcopy Create free account
hub / github.com/Tencent/libco / unsetenv

Function unsetenv

co_hook_sys_call.cpp:804–835  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

802 return g_sys_setenv_func( n,value,overwrite );
803}
804int unsetenv(const char *n)
805{
806 HOOK_SYS_FUNC( unsetenv )
807 if( co_is_enable_sys_hook() && g_co_sysenv.data )
808 {
809 stCoRoutine_t *self = co_self();
810 if( self )
811 {
812 if( !self->pvEnv )
813 {
814 self->pvEnv = dup_co_sysenv_arr( &g_co_sysenv );
815 }
816 stCoSysEnvArr_t *arr = (stCoSysEnvArr_t*)(self->pvEnv);
817
818 stCoSysEnv_t name = { (char*)n,0 };
819
820 stCoSysEnv_t *e = (stCoSysEnv_t*)bsearch( &name,arr->data,arr->cnt,sizeof(name),co_sysenv_comp );
821
822 if( e )
823 {
824 if( e->value )
825 {
826 free( e->value );
827 e->value = 0;
828 }
829 return 0;
830 }
831 }
832
833 }
834 return g_sys_unsetenv_func( n );
835}
836char *getenv( const char *n )
837{
838 HOOK_SYS_FUNC( getenv )

Callers

nothing calls this directly

Calls 3

co_is_enable_sys_hookFunction · 0.85
co_selfFunction · 0.85
dup_co_sysenv_arrFunction · 0.85

Tested by

no test coverage detected