File: SharedMemory.h

package info (click to toggle)
mumble 1.5.735-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 90,008 kB
  • sloc: cpp: 556,921; ansic: 81,662; python: 3,606; sh: 659; makefile: 506; asm: 371; cs: 306; sql: 228; javascript: 143; perl: 80; xml: 13
file content (52 lines) | stat: -rw-r--r-- 912 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2021-2023 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#ifndef MUMBLE_PLUGINS_LINK_SHAREDMEMORY_H_
#define MUMBLE_PLUGINS_LINK_SHAREDMEMORY_H_

#include <cstddef>

#ifdef _WIN32
#	ifndef NOMINMAX
#		define NOMINMAX
#	endif
#	include "windows.h"
#else
#	include <string>
#endif

struct LinkedMem;

class SharedMemory {
public:
	explicit SharedMemory();
	~SharedMemory();

	void close();

	int lastError() const;

	bool mapMemory(const char *name);

	bool isMemoryMapped() const;

	LinkedMem read() const;

	void write(const LinkedMem &source);

	void reset();

private:
	void *m_data;
	int m_error;

#ifdef _WIN32
	HANDLE m_handle;
#else
	std::string m_name;
#endif
};

#endif // MUMBLE_PLUGINS_LINK_SHAREDMEMORY_H_