mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
Check illegal parameter.
This commit is contained in:
parent
e99fe22e9c
commit
6d4cf14132
@ -5,6 +5,7 @@
|
|||||||
#include "libipc/shm.h"
|
#include "libipc/shm.h"
|
||||||
|
|
||||||
#include "libipc/utility/pimpl.h"
|
#include "libipc/utility/pimpl.h"
|
||||||
|
#include "libipc/utility/log.h"
|
||||||
#include "libipc/memory/resource.h"
|
#include "libipc/memory/resource.h"
|
||||||
|
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
@ -68,8 +69,17 @@ void handle::sub_ref() noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool handle::acquire(char const * name, std::size_t size, unsigned mode) {
|
bool handle::acquire(char const * name, std::size_t size, unsigned mode) {
|
||||||
|
if (name == nullptr || name[0] == '\0') {
|
||||||
|
ipc::error("fail acquire: name is empty\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (size == 0) {
|
||||||
|
ipc::error("fail acquire: size is 0\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
release();
|
release();
|
||||||
impl(p_)->id_ = shm::acquire((impl(p_)->n_ = name).c_str(), size, mode);
|
impl(p_)->n_ = name;
|
||||||
|
impl(p_)->id_ = shm::acquire(name, size, mode);
|
||||||
impl(p_)->m_ = shm::get_mem(impl(p_)->id_, &(impl(p_)->s_));
|
impl(p_)->m_ = shm::get_mem(impl(p_)->id_, &(impl(p_)->s_));
|
||||||
return valid();
|
return valid();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user