Skip to content

Commit 7f3a4b7

Browse files
committed
Pass variables by references
1 parent 839b8c9 commit 7f3a4b7

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Shared/mods/deathmatch/logic/luadefs/CLuaCryptDefs.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ int CLuaCryptDefs::EncodeString(lua_State* luaVM)
767767
{
768768
// Execute time-consuming task
769769
SString output;
770-
int result = SharedUtil::ZLibCompress(data, &output, format, compression, strategy);
770+
int result = SharedUtil::ZLibCompress(data, output, format, compression, strategy);
771771
if (result == Z_STREAM_END)
772772
return std::make_pair(output, true);
773773
else
@@ -799,7 +799,7 @@ int CLuaCryptDefs::EncodeString(lua_State* luaVM)
799799
else // Sync
800800
{
801801
SString output;
802-
int result = SharedUtil::ZLibCompress(data, &output, format, compression, strategy);
802+
int result = SharedUtil::ZLibCompress(data, output, format, compression, strategy);
803803
if (result == Z_STREAM_END)
804804
lua::Push(luaVM, output);
805805
else
@@ -1189,7 +1189,7 @@ int CLuaCryptDefs::DecodeString(lua_State* luaVM)
11891189
{
11901190
// Execute time-consuming task
11911191
SString output;
1192-
int result = SharedUtil::ZLibUncompress(data, &output, format);
1192+
int result = SharedUtil::ZLibUncompress(data, output, format);
11931193
if (result == Z_STREAM_END)
11941194
return std::make_pair(output, true);
11951195
else
@@ -1221,7 +1221,7 @@ int CLuaCryptDefs::DecodeString(lua_State* luaVM)
12211221
else // Sync
12221222
{
12231223
SString output;
1224-
int result = SharedUtil::ZLibUncompress(data, &output, format);
1224+
int result = SharedUtil::ZLibUncompress(data, output, format);
12251225
if (result == Z_STREAM_END)
12261226
lua::Push(luaVM, output);
12271227
else

Shared/sdk/SharedUtil.Crypto.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ namespace SharedUtil
204204
return result;
205205
}
206206

207-
inline bool StringToZLibFormat(const std::string format, int &outResult)
207+
inline bool StringToZLibFormat(const std::string& format, int& outResult)
208208
{
209209
int value = atoi(format.c_str());
210210
if ((value >= 9 && value <= 31) || (value >= -15 && value <= -9)) // allowed values: 9..31, -9..-15
@@ -215,7 +215,7 @@ namespace SharedUtil
215215
return false;
216216
}
217217

218-
inline int ZLibCompress(const std::string input, std::string* output, const int windowBits = (int)ZLibFormat::GZIP, const int compression = 9,
218+
inline int ZLibCompress(const std::string& input, std::string& output, const int windowBits = (int)ZLibFormat::GZIP, const int compression = 9,
219219
const ZLibStrategy strategy = ZLibStrategy::DEFAULT)
220220
{
221221
z_stream stream{};
@@ -224,10 +224,10 @@ namespace SharedUtil
224224
if (result != Z_OK)
225225
return result;
226226

227-
output->resize(deflateBound(&stream, input.size())); // resize to the upper bound of what the compressed size might be
227+
output.resize(deflateBound(&stream, input.size())); // resize to the upper bound of what the compressed size might be
228228

229-
stream.next_out = (Bytef*)output->data();
230-
stream.avail_out = output->size();
229+
stream.next_out = (Bytef*)output.data();
230+
stream.avail_out = output.size();
231231

232232
stream.next_in = (z_const Bytef*)input.data();
233233
stream.avail_in = input.size();
@@ -236,12 +236,12 @@ namespace SharedUtil
236236
result |= deflateEnd(&stream);
237237

238238
if (result == Z_STREAM_END)
239-
output->resize(stream.total_out); // resize to the actual size
239+
output.resize(stream.total_out); // resize to the actual size
240240

241241
return result;
242242
}
243243

244-
inline int ZLibUncompress(const std::string& input, std::string* output, int windowBits = 0)
244+
inline int ZLibUncompress(const std::string& input, std::string& output, int windowBits = 0)
245245
{
246246
if (windowBits == 0 && input.size() >= 2) // try to determine format automatically
247247
{
@@ -273,7 +273,7 @@ namespace SharedUtil
273273
if (result != Z_OK && result != Z_STREAM_END)
274274
break;
275275

276-
output->append(buffer, 0, stream.total_out - output->size()); // append only what was written to buffer
276+
output.append(buffer, 0, stream.total_out - output.size()); // append only what was written to buffer
277277

278278
if (result == Z_STREAM_END)
279279
break;

0 commit comments

Comments
 (0)