From 4ad46aa954e0cd6daa0a3eddcb506df3f22882a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 18 Nov 2005 15:35:38 +0000 Subject: [PATCH] Made BMessage::GetInfo() pointer arguments optional (ie. passing NULL doesn't cause a crash anymore). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15022 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/Message4.cpp | 21 ++++++++++++++------- src/kits/app/MessageBody.cpp | 18 +++++------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/kits/app/Message4.cpp b/src/kits/app/Message4.cpp index ad405b28df..5124d520d0 100644 --- a/src/kits/app/Message4.cpp +++ b/src/kits/app/Message4.cpp @@ -213,8 +213,10 @@ BMessage::GetInfo(type_code typeRequested, int32 index, char **nameFound, if (index >= fHeader->fieldCount) return B_BAD_INDEX; - *nameFound = (char *)fData + fFields[index].offset; - *typeFound = fFields[index].type; + if (nameFound) + *nameFound = (char *)fData + fFields[index].offset; + if (typeFound) + *typeFound = fFields[index].type; if (countFound) *countFound = fFields[index].count; return B_OK; @@ -227,8 +229,10 @@ BMessage::GetInfo(type_code typeRequested, int32 index, char **nameFound, counter++; if (counter == index) { - *nameFound = (char *)fData + field->offset; - *typeFound = field->type; + if (nameFound) + *nameFound = (char *)fData + field->offset; + if (typeFound) + *typeFound = field->type; if (countFound) *countFound = field->count; return B_OK; @@ -255,7 +259,8 @@ BMessage::GetInfo(const char *name, type_code *typeFound, int32 *countFound) if (result < B_OK || !field) return result; - *typeFound = field->type; + if (typeFound) + *typeFound = field->type; if (countFound) *countFound = field->count; @@ -273,8 +278,10 @@ BMessage::GetInfo(const char *name, type_code *typeFound, bool *fixedSize) if (result < B_OK || !field) return result; - *typeFound = field->type; - *fixedSize = field->flags & FIELD_FLAG_FIXED_SIZE; + if (typeFound) + *typeFound = field->type; + if (fixedSize) + *fixedSize = field->flags & FIELD_FLAG_FIXED_SIZE; return B_OK; } diff --git a/src/kits/app/MessageBody.cpp b/src/kits/app/MessageBody.cpp index 38bfa514f8..512c595062 100644 --- a/src/kits/app/MessageBody.cpp +++ b/src/kits/app/MessageBody.cpp @@ -128,21 +128,13 @@ status_t BMessageBody::GetInfo(const char* name, type_code* type, { status_t err; BMessageField* BMF = FindData(name, B_ANY_TYPE, err); - if (BMF) - { - *type = BMF->Type(); + if (BMF) { + if (type) + *type = BMF->Type(); if (c) - { *c = BMF->CountItems(); - } - } - else - { - if (c) - { - *c = 0; - } - } + } else if (c) + *c = 0; return err; }