MCPcopy Create free account
hub / github.com/bdring/FluidNC / copyBufferSafe

Method copyBufferSafe

FluidNC/src/WebUI/WebClient.cpp:93–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91 }
92
93 size_t WebClient::copyBufferSafe(uint8_t* dest_buffer, size_t maxLen, size_t total) {
94 xBufferLock.lock();
95 if (_buflen > 0) {
96 int bytes = min(_buflen, maxLen);
97 memcpy(dest_buffer, _buffer, bytes);
98 memmove(_buffer, &_buffer[bytes], _buflen - bytes);
99 _buflen -= bytes;
100 xBufferLock.unlock();
101 return bytes;
102 } else if (done) {
103 free(_buffer);
104 _buffer = nullptr;
105 _allocsize = 0;
106 _buflen = 0;
107 xBufferLock.unlock();
108 return 0;
109 }
110 xBufferLock.unlock();
111 return RESPONSE_TRY_AGAIN;
112 }
113
114 void WebClient::executeCommandBackground(const char* cmd) {
115 xBufferLock.lock();

Callers 1

synchronousCommandMethod · 0.80

Calls 2

lockMethod · 0.80
unlockMethod · 0.80

Tested by

no test coverage detected