[skill][funny] 一个很厉害的for循环
int DSSL_MoveServerToMissingKeyList( DSSL_Env* env, DSSL_ServerInfo* si ) { DSSL_ServerInfo** new_servers = NULL; int i = 0; int ni = 0; int found = 0; _ASSERT( env ); if( env->server_count > 1 ) new_servers = (DSSL_ServerInfo**) malloc( (env->server_count - 1)*sizeof(*env->servers) ); for(i = 0, ni = 0; i < env->server_count; i++) { if(!found && env->servers[i] == si) { DSSL_EnvAddMissingKeyServerInfo( env, si ); found = 1; } else if(new_servers && ni < (env->server_count - 1)) { new_servers[ni] = env->servers[i]; ++ni; } } if(found) { free(env->servers); env->servers = new_servers; --env->server_count; } else if(new_servers) { free(new_servers); new_servers = NULL; } return found; }
from libdssl。