Forgot to commit LinkReceiver... this fixes the build again.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16534 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-02-27 15:06:38 +00:00
parent da0f53d8e4
commit 8c807cddbe
+24 -12
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2005, Haiku. * Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -268,7 +268,7 @@ LinkReceiver::Read(void *data, ssize_t size)
status_t status_t
LinkReceiver::ReadString(char **_string) LinkReceiver::ReadString(char** _string, size_t* _length)
{ {
int32 length = 0; int32 length = 0;
status_t status; status_t status;
@@ -277,18 +277,23 @@ LinkReceiver::ReadString(char **_string)
if (status < B_OK) if (status < B_OK)
return status; return status;
if (length >= 0) { char *string;
char *string = (char *)malloc(length + 1);
if (length < 0) {
status = B_ERROR;
goto err;
}
string = (char *)malloc(length + 1);
if (string == NULL) { if (string == NULL) {
fRecvPosition -= sizeof(int32); // rewind the transaction status = B_NO_MEMORY;
return B_NO_MEMORY; goto err;
} }
if (length > 0) { if (length > 0) {
status = Read(string, length); status = Read(string, length);
if (status < B_OK) { if (status < B_OK) {
free(string); free(string);
fRecvPosition -= sizeof(int32); // rewind the transaction
return status; return status;
} }
} }
@@ -296,17 +301,21 @@ LinkReceiver::ReadString(char **_string)
// make sure the string is null terminated // make sure the string is null terminated
string[length] = '\0'; string[length] = '\0';
if (_length)
*_length = length;
*_string = string; *_string = string;
return B_OK; return B_OK;
} else {
fRecvPosition -= sizeof(int32); // rewind the transaction err:
return B_ERROR; fRecvPosition -= sizeof(int32);
} // rewind the transaction
return status;
} }
status_t status_t
LinkReceiver::ReadString(BString &string) LinkReceiver::ReadString(BString &string, size_t* _length)
{ {
int32 length = 0; int32 length = 0;
status_t status; status_t status;
@@ -339,6 +348,9 @@ LinkReceiver::ReadString(BString &string)
} else } else
string = ""; string = "";
if (_length)
*_length = length;
return B_OK; return B_OK;
err: err: