diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-05-29 21:33:51 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-05-29 21:33:51 +0200 |
| commit | 7fcfa399c5189c29a7e8fc26cbca10b456fa87a4 (patch) | |
| tree | 43b241ae787798ca9cb4af92e333422af4e9f6a0 /src/lib/grok | |
| parent | 6ebae0908fd6a0865962856342c744435696372d (diff) | |
Pass char* into {,de}init_shm().
Diffstat (limited to 'src/lib/grok')
| -rw-r--r-- | src/lib/grok/messenger.cc | 16 | ||||
| -rw-r--r-- | src/lib/grok/shm.cc | 18 | ||||
| -rw-r--r-- | src/lib/grok/shm.h | 4 |
3 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/grok/messenger.cc b/src/lib/grok/messenger.cc index a12ad0486..bed5eaac9 100644 --- a/src/lib/grok/messenger.cc +++ b/src/lib/grok/messenger.cc @@ -131,7 +131,7 @@ Messenger::outbound_thread() int shm_fd = 0; char* send_buffer = nullptr; - if (!init_shm(_outbound_message_buf, messageBufferLen, &shm_fd, &send_buffer)) { + if (!init_shm(_outbound_message_buf.c_str(), messageBufferLen, &shm_fd, &send_buffer)) { return; } @@ -151,7 +151,7 @@ Messenger::outbound_thread() _outbound_synch->post(SYNCH_SENT); } - ::deinit_shm(_outbound_message_buf, messageBufferLen, shm_fd, &send_buffer); + ::deinit_shm(_outbound_message_buf.c_str(), messageBufferLen, shm_fd, &send_buffer); } @@ -161,7 +161,7 @@ Messenger::inbound_thread() int shm_fd = 0; char* receive_buffer = nullptr; - if (!init_shm(_inbound_message_buf, messageBufferLen, &shm_fd, &receive_buffer)) { + if (!init_shm(_inbound_message_buf.c_str(), messageBufferLen, &shm_fd, &receive_buffer)) { return; } @@ -175,7 +175,7 @@ Messenger::inbound_thread() _receive_queue.push(message); } - ::deinit_shm(_inbound_message_buf, messageBufferLen, shm_fd, &receive_buffer); + ::deinit_shm(_inbound_message_buf.c_str(), messageBufferLen, shm_fd, &receive_buffer); } @@ -200,7 +200,7 @@ Messenger::initBuffers() bool rc = true; if (_uncompressed_frame_size) { rc = rc && init_shm( - grokUncompressedBuf, + grokUncompressedBuf.c_str(), _uncompressed_frame_size * _num_frames, &_uncompressed_fd, &_uncompressed_buffer ); @@ -208,7 +208,7 @@ Messenger::initBuffers() if (_compressed_frame_size) { rc = rc && init_shm( - grokCompressedBuf, + grokCompressedBuf.c_str(), _compressed_frame_size * _num_frames, &_compressed_fd, &_compressed_buffer ); @@ -222,13 +222,13 @@ bool Messenger::deinit_shm() { bool rc = ::deinit_shm( - grokUncompressedBuf, + grokUncompressedBuf.c_str(), _uncompressed_frame_size * _num_frames, _uncompressed_fd, &_uncompressed_buffer ); rc = rc && ::deinit_shm( - grokCompressedBuf, + grokCompressedBuf.c_str(), _compressed_frame_size * _num_frames, _compressed_fd, &_compressed_buffer ); diff --git a/src/lib/grok/shm.cc b/src/lib/grok/shm.cc index 91fe28903..41fe8169a 100644 --- a/src/lib/grok/shm.cc +++ b/src/lib/grok/shm.cc @@ -24,9 +24,9 @@ bool -grk_plugin::init_shm(std::string const& name, size_t len, int* shm_fd, char** buffer) +grk_plugin::init_shm(char const* name, size_t len, int* shm_fd, char** buffer) { - *shm_fd = shm_open(name.c_str(), O_CREAT | O_RDWR, 0666); + *shm_fd = shm_open(name, O_CREAT | O_RDWR, 0666); if (*shm_fd < 0) { getMessengerLogger()->error("Error opening shared memory: %s", strerror(errno)); @@ -40,7 +40,7 @@ grk_plugin::init_shm(std::string const& name, size_t len, int* shm_fd, char** bu if (close(*shm_fd)) { getMessengerLogger()->error("Error closing shared memory: %s", strerror(errno)); } - rc = shm_unlink(name.c_str()); + rc = shm_unlink(name); if (rc && errno != ENOENT) { getMessengerLogger()->error("Error unlinking shared memory: %s", strerror(errno)); } @@ -54,7 +54,7 @@ grk_plugin::init_shm(std::string const& name, size_t len, int* shm_fd, char** bu if (close(*shm_fd)) { getMessengerLogger()->error("Error closing shared memory: %s", strerror(errno)); } - rc = shm_unlink(name.c_str()); + rc = shm_unlink(name); if (rc && errno != ENOENT) { getMessengerLogger()->error("Error unlinking shared memory: %s", strerror(errno)); } @@ -65,7 +65,7 @@ grk_plugin::init_shm(std::string const& name, size_t len, int* shm_fd, char** bu bool -grk_plugin::deinit_shm(const std::string &name, size_t len, int &shm_fd, char** buffer) +grk_plugin::deinit_shm(char const* name, size_t len, int &shm_fd, char** buffer) { if (!*buffer || !shm_fd) { return true; @@ -75,20 +75,20 @@ grk_plugin::deinit_shm(const std::string &name, size_t len, int &shm_fd, char** *buffer = nullptr; if (rc) { - getMessengerLogger()->error("Error unmapping shared memory %s: %s", name.c_str(), strerror(errno)); + getMessengerLogger()->error("Error unmapping shared memory %s: %s", name, strerror(errno)); } rc = close(shm_fd); shm_fd = 0; if (rc) { - getMessengerLogger()->error("Error closing shared memory %s: %s", name.c_str(), strerror(errno)); + getMessengerLogger()->error("Error closing shared memory %s: %s", name, strerror(errno)); } - rc = shm_unlink(name.c_str()); + rc = shm_unlink(name); if (rc && errno != ENOENT) { - getMessengerLogger()->error("Error unlinking shared memory %s : %s", name.c_str(), strerror(errno)); + getMessengerLogger()->error("Error unlinking shared memory %s : %s", name, strerror(errno)); } return true; diff --git a/src/lib/grok/shm.h b/src/lib/grok/shm.h index f9fa5f93d..45abc71d6 100644 --- a/src/lib/grok/shm.h +++ b/src/lib/grok/shm.h @@ -25,8 +25,8 @@ namespace grk_plugin { -bool init_shm(std::string const& name, size_t len, int* shm_fd, char** buffer); -bool deinit_shm(std::string const& name, size_t len, int &shm_fd, char** buffer); +bool init_shm(char const* name, size_t len, int* shm_fd, char** buffer); +bool deinit_shm(char const* name, size_t len, int &shm_fd, char** buffer); } |
