Author: oruizdorantes Date: 2010-01-03 22:30:26 +0100 (Sun, 03 Jan 2010) New Revision: 34881 Changeset: http://dev.haiku-os.org/changeset/34881/haiku Modified: haiku/trunk/headers/private/bluetooth/PortListener.h Log: - Port & Thread string's name allocation was messed and used in InitCheck. - Style, spacing binary operator Modified: haiku/trunk/headers/private/bluetooth/PortListener.h =================================================================== --- haiku/trunk/headers/private/bluetooth/PortListener.h 2010-01-03 21:19:47 UTC (rev 34880) +++ haiku/trunk/headers/private/bluetooth/PortListener.h 2010-01-03 21:30:26 UTC (rev 34881) @@ -22,10 +22,13 @@ fInformation.func = handler; fInformation.port = &fPort; - InitCheck(); fPortName = strdup(name); - fThreadName = strdup(name); + + fThreadName = (char*)malloc(strlen(name) + strlen(" thread") + 1); + fThreadName = strcpy(fThreadName, fPortName); fThreadName = strcat(fThreadName, " thread"); + + InitCheck(); } @@ -37,8 +40,8 @@ // Closing the port should provoke the thread to finish wait_for_thread(fThread, &status); - delete fThreadName; - delete fPortName; + free(fThreadName); + free(fPortName); } @@ -52,7 +55,7 @@ { if (buffer == NULL) return B_ERROR; - + if (size == 0) return write_port(fPort, code, buffer, sizeof(TYPE)); else @@ -68,7 +71,7 @@ fPort = create_port(MAX_MESSAGE_DEEP, fPortName); } - if (fPort < B_OK) + if (fPort < B_OK) return fPort; // Create Thread @@ -96,7 +99,7 @@ status_t Launch() { status_t check = InitCheck(); - + if (check < B_OK) return check; @@ -144,12 +147,12 @@ while ((ssizePort = port_buffer_size(*port)) != B_BAD_PORT_ID) { if (ssizePort <= 0) { - snooze(500*1000); + snooze(500 * 1000); continue; } if (ssizePort > MAX_MESSAGE_SIZE) { - snooze(500*1000); + snooze(500 * 1000); continue; } @@ -168,7 +171,7 @@ if (ssizePort == B_BAD_PORT_ID) // the port disappeared return ssizePort; - + return status; }