From Adrien Destugues <pulkomandy@xxxxxxxxx>:
Hello X512,
I'd like you to do a code review. Please visit
https://review.haiku-os.org/c/haiku/+/3174
to review the following change.
Change subject: app_server pointer/ownership cleanup: trivial changes
......................................................................
app_server pointer/ownership cleanup: trivial changes
Split apart the work done in https://review.haiku-os.org/c/haiku/+/2695
in smaller, easier to review parts.
This commit contains self-contained/local changes that are unlikely to
cause problems.
---
M src/servers/app/AppServer.cpp
M src/servers/app/CursorSet.cpp
M src/servers/app/EventStream.cpp
3 files changed, 12 insertions(+), 13 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/74/3174/1
diff --git a/src/servers/app/AppServer.cpp b/src/servers/app/AppServer.cpp
index a0601ce..c904170 100644
--- a/src/servers/app/AppServer.cpp
+++ b/src/servers/app/AppServer.cpp
@@ -14,6 +14,7 @@
#include <syslog.h>
+#include <AutoDeleter.h>
#include <LaunchRoster.h>
#include <PortLink.h>
@@ -174,20 +175,19 @@
AppServer::_CreateDesktop(uid_t userID, const char* targetScreen)
{
BAutolock locker(fDesktopLock);
- Desktop* desktop = NULL;
+ ObjectDeleter<Desktop> desktop;
try {
- desktop = new Desktop(userID, targetScreen);
+ desktop.SetTo(new Desktop(userID, targetScreen));
status_t status = desktop->Init();
if (status == B_OK)
status = desktop->Run();
- if (status == B_OK && !fDesktops.AddItem(desktop))
+ if (status == B_OK && !fDesktops.AddItem(desktop.Get()))
status = B_NO_MEMORY;
if (status != B_OK) {
syslog(LOG_ERR, "Cannot initialize Desktop object:
%s\n",
strerror(status));
- delete desktop;
return NULL;
}
} catch (...) {
@@ -195,7 +195,7 @@
return NULL;
}
- return desktop;
+ return desktop.Detach();
}
diff --git a/src/servers/app/CursorSet.cpp b/src/servers/app/CursorSet.cpp
index 67c7149..faa3aa4 100644
--- a/src/servers/app/CursorSet.cpp
+++ b/src/servers/app/CursorSet.cpp
@@ -132,12 +132,11 @@
if (data == NULL)
return B_BAD_VALUE;
- BBitmap *bitmap = _CursorDataToBitmap(data);
+ ObjectDeleter<BBitmap> bitmap(_CursorDataToBitmap(data));
BPoint hotspot(data[2], data[3]);
- status_t result = AddCursor(which, bitmap, hotspot);
+ status_t result = AddCursor(which, bitmap.Get(), hotspot);
- delete bitmap;
return result;
}
diff --git a/src/servers/app/EventStream.cpp b/src/servers/app/EventStream.cpp
index bb0f0de..d857176 100644
--- a/src/servers/app/EventStream.cpp
+++ b/src/servers/app/EventStream.cpp
@@ -13,6 +13,7 @@
#include <ServerProtocol.h>
#include <shared_cursor_area.h>
+#include <AutoDeleter.h>
#include <AppMisc.h>
#include <new>
@@ -262,12 +263,12 @@
// we have the message, now let's unflatten it
- BMessage* message = new BMessage(code);
- if (message == NULL)
+ ObjectDeleter<BMessage> message(new BMessage(code));
+ if (message.Get() == NULL)
return B_NO_MEMORY;
if (buffer == NULL) {
- *_message = message;
+ *_message = message.Detach();
return B_OK;
}
@@ -278,11 +279,10 @@
printf("Unflatten event failed: %s, port message code was: %"
B_PRId32
" - %c%c%c%c\n", strerror(status), code, (int8)(code >>
24),
(int8)(code >> 16), (int8)(code >> 8), (int8)code);
- delete message;
return status;
}
- *_message = message;
+ *_message = message.Detach();
return B_OK;
}
--
To view, visit https://review.haiku-os.org/c/haiku/+/3174
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: Idae27ca440791423e3d090bcfe33f4cc83bbea3d
Gerrit-Change-Number: 3174
Gerrit-PatchSet: 1
Gerrit-Owner: Adrien Destugues <pulkomandy@xxxxxxxxx>
Gerrit-Reviewer: X512 <danger_mail@xxxxxxx>
Gerrit-MessageType: newchange