From f7397837e8e8749d0a2cdf2725262f00ccd74995 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 24 May 2019 14:28:19 -0400 Subject: [PATCH] BMessage: Use assignment operator instead of memcpy(). The only non-POD types the macro is used on are BPoint, BRect, BSize, and rgb_color, so the first change should essentially be a no-op. The second change will technically have different behavior, as the BMessenger copy constructor does not touch the _reserved_ field; but this shouldn't break anything, of course. --- src/kits/app/Message.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp index 01699b3ebd..a111a294bf 100644 --- a/src/kits/app/Message.cpp +++ b/src/kits/app/Message.cpp @@ -2438,24 +2438,14 @@ BMessage::Add##typeName(const char* name, type val) \ status_t \ BMessage::Find##typeName(const char* name, type* p) const \ { \ - void* ptr = NULL; \ - ssize_t bytes = 0; \ - status_t error = B_OK; \ - \ - *p = type(); \ - error = FindData(name, typeCode, 0, (const void**)&ptr, &bytes); \ - \ - if (error == B_OK) \ - memcpy(p, ptr, sizeof(type)); \ - \ - return error; \ + return Find##typeName(name, 0, p); \ } \ \ \ status_t \ BMessage::Find##typeName(const char* name, int32 index, type* p) const \ { \ - void* ptr = NULL; \ + type* ptr = NULL; \ ssize_t bytes = 0; \ status_t error = B_OK; \ \ @@ -2463,7 +2453,7 @@ BMessage::Find##typeName(const char* name, int32 index, type* p) const \ error = FindData(name, typeCode, index, (const void**)&ptr, &bytes); \ \ if (error == B_OK) \ - memcpy(p, ptr, sizeof(type)); \ + *p = *ptr; \ \ return error; \ } \ @@ -2957,13 +2947,13 @@ BMessage::FindMessenger(const char* name, int32 index, if (messenger == NULL) return B_BAD_VALUE; - void* data = NULL; + BMessenger* data = NULL; ssize_t size = 0; status_t error = FindData(name, B_MESSENGER_TYPE, index, (const void**)&data, &size); if (error == B_OK) - memcpy(messenger, data, sizeof(BMessenger)); + *messenger = *data; else *messenger = BMessenger();