vfs: check userland buffers before reading them.
[haiku.git] / src / servers / app / IntPoint.cpp
blobd974e49e869161234db8a6f186029e4a8c6b8b7b
1 /*
2 * Copyright 2001-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Frans van Nispen
7 * Stephan Aßmus <superstippi@gmx.de>
8 */
11 #include "IntPoint.h"
13 #include <stdio.h>
15 #include "IntRect.h"
18 void
19 IntPoint::ConstrainTo(const IntRect& r)
21 x = max_c(min_c(x, r.right), r.left);
22 y = max_c(min_c(y, r.bottom), r.top);
26 void
27 IntPoint::PrintToStream() const
29 printf("IntPoint(x:%" B_PRId32 ", y:%" B_PRId32 ")\n", x, y);
33 IntPoint
34 IntPoint::operator+(const IntPoint& p) const
36 return IntPoint(x + p.x, y + p.y);
40 IntPoint
41 IntPoint::operator-(const IntPoint& p) const
43 return IntPoint(x - p.x, y - p.y);
47 IntPoint &
48 IntPoint::operator+=(const IntPoint& p)
50 x += p.x;
51 y += p.y;
53 return *this;
57 IntPoint &
58 IntPoint::operator-=(const IntPoint& p)
60 x -= p.x;
61 y -= p.y;
63 return *this;
67 bool
68 IntPoint::operator!=(const IntPoint& p) const
70 return x != p.x || y != p.y;
74 bool
75 IntPoint::operator==(const IntPoint& p) const
77 return x == p.x && y == p.y;