status_t SetAuthentication(const char* share, const char* user, const char* password) { // check, if an entry already exists for the share -- if it does, // just set it Authentication* authentication = fAuthentications.Get(share); if (authentication) return authentication->SetTo(user, password); // the entry does not exist yet: create and add a new one authentication = new(nothrow) Authentication; if (!authentication) return B_NO_MEMORY; status_t error = authentication->SetTo(user, password); if (error == B_OK) error = fAuthentications.Put(share, authentication); if (error != B_OK) delete authentication; return error; }