vfs: check userland buffers before reading them.
[haiku.git] / src / kits / app / DirectMessageTarget.cpp
blob8f0d8ce731d3570fdbd5fb14fc09a282d0912545
1 /*
2 * Copyright 2007, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, axeld@pinc-software.de
7 */
10 #include <DirectMessageTarget.h>
13 namespace BPrivate {
16 BDirectMessageTarget::BDirectMessageTarget()
18 fReferenceCount(1),
19 fClosed(false)
24 BDirectMessageTarget::~BDirectMessageTarget()
29 bool
30 BDirectMessageTarget::AddMessage(BMessage* message)
32 if (fClosed) {
33 delete message;
34 return false;
37 fQueue.AddMessage(message);
38 return true;
42 void
43 BDirectMessageTarget::Close()
45 fClosed = true;
49 void
50 BDirectMessageTarget::Acquire()
52 atomic_add(&fReferenceCount, 1);
56 void
57 BDirectMessageTarget::Release()
59 if (atomic_add(&fReferenceCount, -1) == 1)
60 delete this;
63 } // namespace BPrivate