Skip to content

Commit cf87ad8

Browse files
committed
Update
1 parent ea66dcf commit cf87ad8

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group 'cn.apisium.shm'
7-
version '0.1.1'
7+
version '0.1.2'
88

99
sourceCompatibility = JavaVersion.VERSION_19
1010
targetCompatibility = JavaVersion.VERSION_19

include/jshm.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@ namespace jshm {
1919

2020
~shared_memory() {
2121
#ifdef _WIN32
22-
UnmapViewOfFile(pBuf);
22+
UnmapViewOfFile(_pBuf);
2323
CloseHandle(hMapFile);
2424
#elif __linux__ || __APPLE__
25-
if (pBuf) munmap(pBuf, _size);
25+
if (_pBuf) munmap(_pBuf, (size_t) _size);
2626
if (_isCreate) shm_unlink(_name);
2727
#endif
2828
}
2929

30-
[[nodiscard]] void* address() const noexcept { return pBuf; }
30+
[[nodiscard]] void* address() const noexcept { return _pBuf; }
3131

3232
[[nodiscard]] static shared_memory* create(const char* name, int size) { return init(name, size, true); }
3333
[[nodiscard]] static shared_memory* open(const char* name, int size) { return init(name, size, false); }
34-
34+
3535
private:
3636
int _size;
3737
const char* _name;
38-
38+
3939
#ifdef _WIN32
4040
HANDLE hMapFile;
41-
LPTSTR pBuf;
42-
41+
LPTSTR _pBuf;
42+
4343
shared_memory(HANDLE hMapFile, LPTSTR pBuf, int size, const char* name) : hMapFile(hMapFile), pBuf(pBuf), _size(size), _name(name) { }
4444
#elif __linux__ || __APPLE__
45-
void* pBuf = nullptr;
45+
void* _pBuf = nullptr;
4646
bool _isCreate;
47-
shared_memory(void* pBuf, int size, const char* name, bool isCreate) : pBuf(pBuf), _size(size), _name(name), _isCreate(isCreate) { }
47+
shared_memory(void* pBuf, int size, const char* name, bool isCreate) : _size(size), _name(name), _pBuf(pBuf), _isCreate(isCreate) { }
4848
#endif
4949

5050
static shared_memory* init(const char* name, int size, bool isCreate) {
@@ -65,7 +65,7 @@ namespace jshm {
6565
close(fd);
6666
return nullptr;
6767
}
68-
auto pBuf = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
68+
auto pBuf = mmap(nullptr, (size_t) size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
6969
if (pBuf == MAP_FAILED) {
7070
close(fd);
7171
return nullptr;

0 commit comments

Comments
 (0)