SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThreadsafePacketLogger.cpp
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
16 #include "slikenet/NativeFeatureIncludes.h"
17 #if _RAKNET_SUPPORT_PacketLogger==1
18
19 #include "slikenet/ThreadsafePacketLogger.h"
20 #include <string.h>
21 #include "slikenet/linux_adapter.h"
22 #include "slikenet/osx_adapter.h"
23
24 using namespace SLNet;
25
26 ThreadsafePacketLogger::ThreadsafePacketLogger()
27 {
28
29 }
30 ThreadsafePacketLogger::~ThreadsafePacketLogger()
31 {
32 char **msg;
33 while ((msg = logMessages.ReadLock()) != 0)
34 {
35 rakFree_Ex((*msg), _FILE_AND_LINE_ );
36 }
37 }
38 void ThreadsafePacketLogger::Update(void)
39 {
40 char **msg;
41 while ((msg = logMessages.ReadLock()) != 0)
42 {
43 WriteLog(*msg);
44 rakFree_Ex((*msg), _FILE_AND_LINE_ );
45 }
46 }
47 void ThreadsafePacketLogger::AddToLog(const char *str)
48 {
49 char **msg = logMessages.WriteLock();
50 *msg = (char*) rakMalloc_Ex( strlen(str)+1, _FILE_AND_LINE_ );
51 strcpy_s(*msg, strlen(str)+1, str);
52 logMessages.WriteUnlock();
53 }
54
55 #endif // _RAKNET_SUPPORT_*