From 8c807cddbea62fad09a7c1605c532e4357537a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 27 Feb 2006 15:06:38 +0000 Subject: [PATCH] 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 --- src/kits/app/LinkReceiver.cpp | 64 +++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/src/kits/app/LinkReceiver.cpp b/src/kits/app/LinkReceiver.cpp index 8dcc325284..84e1d7e1dd 100644 --- a/src/kits/app/LinkReceiver.cpp +++ b/src/kits/app/LinkReceiver.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku. + * Copyright 2001-2006, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -268,7 +268,7 @@ LinkReceiver::Read(void *data, ssize_t size) status_t -LinkReceiver::ReadString(char **_string) +LinkReceiver::ReadString(char** _string, size_t* _length) { int32 length = 0; status_t status; @@ -277,36 +277,45 @@ LinkReceiver::ReadString(char **_string) if (status < B_OK) return status; - if (length >= 0) { - char *string = (char *)malloc(length + 1); - if (string == NULL) { - fRecvPosition -= sizeof(int32); // rewind the transaction - return B_NO_MEMORY; - } + char *string; - if (length > 0) { - status = Read(string, length); - if (status < B_OK) { - free(string); - fRecvPosition -= sizeof(int32); // rewind the transaction - return status; - } - } - - // make sure the string is null terminated - string[length] = '\0'; - - *_string = string; - return B_OK; - } else { - fRecvPosition -= sizeof(int32); // rewind the transaction - return B_ERROR; + if (length < 0) { + status = B_ERROR; + goto err; } + + string = (char *)malloc(length + 1); + if (string == NULL) { + status = B_NO_MEMORY; + goto err; + } + + if (length > 0) { + status = Read(string, length); + if (status < B_OK) { + free(string); + return status; + } + } + + // make sure the string is null terminated + string[length] = '\0'; + + if (_length) + *_length = length; + *_string = string; + + return B_OK; + +err: + fRecvPosition -= sizeof(int32); + // rewind the transaction + return status; } status_t -LinkReceiver::ReadString(BString &string) +LinkReceiver::ReadString(BString &string, size_t* _length) { int32 length = 0; status_t status; @@ -339,6 +348,9 @@ LinkReceiver::ReadString(BString &string) } else string = ""; + if (_length) + *_length = length; + return B_OK; err: