diff --git a/src/system/kernel/port.cpp b/src/system/kernel/port.cpp index 26e00d26ed..6d92e92172 100644 --- a/src/system/kernel/port.cpp +++ b/src/system/kernel/port.cpp @@ -132,7 +132,7 @@ struct Port : public KernelReferenceable { select_info* select_infos; MessageList messages; - Port(team_id owner, int32 queueLength, char* name) + Port(team_id owner, int32 queueLength, const char* name) : owner(owner), name_hash(0), @@ -145,7 +145,7 @@ struct Port : public KernelReferenceable { { // id is initialized when the caller adds the port to the hash table - mutex_init(&lock, name); + mutex_init_etc(&lock, name, MUTEX_FLAG_CLONE_NAME); read_condition.Init(this, "port read"); write_condition.Init(this, "port write"); } @@ -155,8 +155,7 @@ struct Port : public KernelReferenceable { while (port_message* message = messages.RemoveHead()) put_port_message(message); - free((char*)lock.name); - lock.name = NULL; + mutex_destroy(&lock); } }; @@ -988,18 +987,11 @@ create_port(int32 queueLength, const char* name) if (team == NULL) return B_BAD_TEAM_ID; - // check & dup name - char* nameBuffer = strdup(name != NULL ? name : "unnamed port"); - if (nameBuffer == NULL) - return B_NO_MEMORY; - // create a port Port* port = new(std::nothrow) Port(team_get_current_team_id(), queueLength, - nameBuffer); - if (port == NULL) { - free(nameBuffer); + name != NULL ? name : "unnamed port"); + if (port == NULL) return B_NO_MEMORY; - } // check the ports limit const int32 previouslyUsed = atomic_add(&sUsedPorts, 1);