mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 07:43:35 +02:00
fix memory breakages after previous change
This commit is contained in:
parent
0f9d72e2c1
commit
cc4492bad8
1 changed files with 13 additions and 12 deletions
|
@ -66,7 +66,7 @@ int main(int argc, const char* argv[]) {
|
||||||
char deviceAddress[INET_ADDRSTRLEN] = {};
|
char deviceAddress[INET_ADDRSTRLEN] = {};
|
||||||
int socketPort = 0;
|
int socketPort = 0;
|
||||||
|
|
||||||
int numMatches = sscanf(senderData, "Available %s%[^:]:%d %s",
|
int numMatches = sscanf(senderData, "Available %s %[^:]:%d %s",
|
||||||
tempDevice.identifier,
|
tempDevice.identifier,
|
||||||
deviceAddress,
|
deviceAddress,
|
||||||
&socketPort,
|
&socketPort,
|
||||||
|
@ -74,24 +74,25 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
if (numMatches >= 3) {
|
if (numMatches >= 3) {
|
||||||
// if we have fewer than 3 matches the packet wasn't properly formatted
|
// if we have fewer than 3 matches the packet wasn't properly formatted
|
||||||
// otherwise copy the tempDevice to the persisting lastDevice
|
|
||||||
*::lastDevice = tempDevice;
|
|
||||||
|
|
||||||
// setup the localSocket for the pairing device
|
// setup the localSocket for the pairing device
|
||||||
::lastDevice->localSocket.sin_family = AF_INET;
|
tempDevice.localSocket.sin_family = AF_INET;
|
||||||
inet_pton(AF_INET, deviceAddress, &::lastDevice);
|
inet_pton(AF_INET, deviceAddress, &::lastDevice);
|
||||||
::lastDevice->localSocket.sin_port = socketPort;
|
tempDevice.localSocket.sin_port = socketPort;
|
||||||
|
|
||||||
// store this device's sending socket so we can talk back to it
|
// store this device's sending socket so we can talk back to it
|
||||||
::lastDevice->sendingSocket = senderSocket;
|
tempDevice.sendingSocket = senderSocket;
|
||||||
|
|
||||||
// push this new device into the vector
|
// push this new device into the vector
|
||||||
printf("Adding device %s (%s) - %s:%d to list\n",
|
printf("New last device is %s (%s) at %s:%d\n",
|
||||||
::lastDevice->identifier,
|
tempDevice.identifier,
|
||||||
::lastDevice->name,
|
tempDevice.name,
|
||||||
deviceAddress,
|
deviceAddress,
|
||||||
socketPort);
|
socketPort);
|
||||||
|
|
||||||
|
// copy the tempDevice to the persisting lastDevice
|
||||||
|
::lastDevice = new PairableDevice(tempDevice);
|
||||||
|
|
||||||
if (::lastClient) {
|
if (::lastClient) {
|
||||||
sendLastClientToLastDevice();
|
sendLastClientToLastDevice();
|
||||||
}
|
}
|
||||||
|
@ -108,9 +109,9 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
if (requestorMatches == 2) {
|
if (requestorMatches == 2) {
|
||||||
// good data, copy the tempClient to the persisting lastInterfaceClient
|
// good data, copy the tempClient to the persisting lastInterfaceClient
|
||||||
*::lastClient = tempClient;
|
::lastClient = new RequestingClient(tempClient);
|
||||||
|
|
||||||
printf("Find request from interface client at %s:%d\n",
|
printf("New last client is at %s:%d\n",
|
||||||
::lastClient->address,
|
::lastClient->address,
|
||||||
::lastClient->port);
|
::lastClient->port);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue