mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
SVNetwork: Avoid unneeded new / delete operations
The class variable mutex_send_ does not require an indirection by using a pointer. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
83588bc7a1
commit
6d19e7c3c0
@ -208,19 +208,19 @@ void SVSemaphore::Wait() {
|
||||
|
||||
// Place a message in the message buffer (and flush it).
|
||||
void SVNetwork::Send(const char* msg) {
|
||||
mutex_send_->Lock();
|
||||
mutex_send_.Lock();
|
||||
msg_buffer_out_.append(msg);
|
||||
mutex_send_->Unlock();
|
||||
mutex_send_.Unlock();
|
||||
}
|
||||
|
||||
// Send the whole buffer.
|
||||
void SVNetwork::Flush() {
|
||||
mutex_send_->Lock();
|
||||
mutex_send_.Lock();
|
||||
while (!msg_buffer_out_.empty()) {
|
||||
int i = send(stream_, msg_buffer_out_.c_str(), msg_buffer_out_.length(), 0);
|
||||
msg_buffer_out_.erase(0, i);
|
||||
}
|
||||
mutex_send_->Unlock();
|
||||
mutex_send_.Unlock();
|
||||
}
|
||||
|
||||
// Receive a message from the server.
|
||||
@ -387,7 +387,6 @@ static int GetAddrInfo(const char* hostname, int port,
|
||||
|
||||
// Set up a connection to a ScrollView on hostname:port.
|
||||
SVNetwork::SVNetwork(const char* hostname, int port) {
|
||||
mutex_send_ = new SVMutex();
|
||||
msg_buffer_in_ = new char[kMaxMsgSize + 1];
|
||||
msg_buffer_in_[0] = '\0';
|
||||
|
||||
@ -448,7 +447,6 @@ SVNetwork::SVNetwork(const char* hostname, int port) {
|
||||
|
||||
SVNetwork::~SVNetwork() {
|
||||
delete[] msg_buffer_in_;
|
||||
delete mutex_send_;
|
||||
}
|
||||
|
||||
#endif // GRAPHICS_DISABLED
|
||||
|
@ -141,7 +141,7 @@ class SVNetwork {
|
||||
|
||||
private:
|
||||
/// The mutex for access to Send() and Flush().
|
||||
SVMutex* mutex_send_;
|
||||
SVMutex mutex_send_;
|
||||
/// The actual stream_ to the server.
|
||||
int stream_;
|
||||
/// Stores the last received message-chunk from the server.
|
||||
|
Loading…
Reference in New Issue
Block a user