all: yet more minor updates

This commit is contained in:
Markus F.X.J. Oberhumer
2023-06-09 14:12:05 +02:00
parent db39f9c4dc
commit 19e84fea62
37 changed files with 192 additions and 164 deletions
+2 -2
View File
@@ -130,7 +130,7 @@ inline typename MemBufferBase<T>::pointer raw_index_bytes(const MemBufferBase<T>
#undef XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION
/*************************************************************************
//
// MemBuffer
**************************************************************************/
class MemBuffer final : public MemBufferBase<byte> {
@@ -185,7 +185,7 @@ private:
void *last_return_address_dealloc;
void *last_return_address_fill;
void *last_return_address_subref;
Debug() { memset(this, 0, sizeof(*this)); }
Debug() noexcept { memset(this, 0, sizeof(*this)); }
};
Debug debug;
#endif
-4
View File
@@ -26,8 +26,6 @@
*/
#pragma once
#ifndef UPX_SNPRINTF_H__
#define UPX_SNPRINTF_H__ 1
/*************************************************************************
// UPX version of string functions, with assertions and sane limits
@@ -87,6 +85,4 @@ forceinline upx_rsize_t upx_safe_strlen(const uchar *s) {
return upx_safe_strlen((const char *) s);
}
#endif /* already included */
/* vim:set ts=4 sw=4 et: */
+8 -8
View File
@@ -445,7 +445,7 @@ int __acc_cdecl_qsort le64_compare_signed(const void *e1, const void *e2) {
// find and mem_replace util
**************************************************************************/
int find(const void *buf, int blen, const void *what, int wlen) {
int find(const void *buf, int blen, const void *what, int wlen) noexcept {
// nullptr is explicitly allowed here
if (buf == nullptr || blen < wlen || what == nullptr || wlen <= 0)
return -1;
@@ -461,37 +461,37 @@ int find(const void *buf, int blen, const void *what, int wlen) {
return -1;
}
int find_be16(const void *b, int blen, unsigned what) {
int find_be16(const void *b, int blen, unsigned what) noexcept {
byte w[2];
set_be16(w, what);
return find(b, blen, w, 2);
}
int find_be32(const void *b, int blen, unsigned what) {
int find_be32(const void *b, int blen, unsigned what) noexcept {
byte w[4];
set_be32(w, what);
return find(b, blen, w, 4);
}
int find_be64(const void *b, int blen, upx_uint64_t what) {
int find_be64(const void *b, int blen, upx_uint64_t what) noexcept {
byte w[8];
set_be64(w, what);
return find(b, blen, w, 8);
}
int find_le16(const void *b, int blen, unsigned what) {
int find_le16(const void *b, int blen, unsigned what) noexcept {
byte w[2];
set_le16(w, what);
return find(b, blen, w, 2);
}
int find_le32(const void *b, int blen, unsigned what) {
int find_le32(const void *b, int blen, unsigned what) noexcept {
byte w[4];
set_le32(w, what);
return find(b, blen, w, 4);
}
int find_le64(const void *b, int blen, upx_uint64_t what) {
int find_le64(const void *b, int blen, upx_uint64_t what) noexcept {
byte w[8];
set_le64(w, what);
return find(b, blen, w, 8);
@@ -518,7 +518,7 @@ TEST_CASE("find") {
CHECK(find_le64(b, 15, 0x0f0e0d0c0b0a0908ULL) == -1);
}
int mem_replace(void *buf, int blen, const void *what, int wlen, const void *replacement) {
int mem_replace(void *buf, int blen, const void *what, int wlen, const void *replacement) noexcept {
byte *b = (byte *) buf;
int boff = 0;
int n = 0;
+10 -14
View File
@@ -26,8 +26,6 @@
*/
#pragma once
#ifndef UPX_UTIL_H__
#define UPX_UTIL_H__ 1
/*************************************************************************
// assert sane memory buffer sizes to protect against integer overflows
@@ -80,13 +78,13 @@ template <class T>
T *NewArray(upx_uint64_t n) {
size_t bytes = mem_size(sizeof(T), n); // assert size
T *array = new T[size_t(n)];
if (array) {
if (array != nullptr && bytes > 0) {
memset(array, 0xfb, bytes);
(void) VALGRIND_MAKE_MEM_UNDEFINED(array, bytes);
}
return array;
}
#define New(type, n) (NewArray<type>(n))
#define New(type, n) (NewArray<type>((n)))
#else
#define New(type, n) new type[mem_size_get_n(sizeof(type), (n))]
#endif
@@ -142,15 +140,15 @@ void upx_stable_sort(void *array, size_t n, size_t element_size,
// misc. support functions
**************************************************************************/
int find(const void *b, int blen, const void *what, int wlen);
int find_be16(const void *b, int blen, unsigned what);
int find_be32(const void *b, int blen, unsigned what);
int find_be64(const void *b, int blen, upx_uint64_t what);
int find_le16(const void *b, int blen, unsigned what);
int find_le32(const void *b, int blen, unsigned what);
int find_le64(const void *b, int blen, upx_uint64_t what);
int find(const void *b, int blen, const void *what, int wlen) noexcept;
int find_be16(const void *b, int blen, unsigned what) noexcept;
int find_be32(const void *b, int blen, unsigned what) noexcept;
int find_be64(const void *b, int blen, upx_uint64_t what) noexcept;
int find_le16(const void *b, int blen, unsigned what) noexcept;
int find_le32(const void *b, int blen, unsigned what) noexcept;
int find_le64(const void *b, int blen, upx_uint64_t what) noexcept;
int mem_replace(void *b, int blen, const void *what, int wlen, const void *r);
int mem_replace(void *b, int blen, const void *what, int wlen, const void *r) noexcept;
char *fn_basename(const char *name);
int fn_strcmp(const char *n1, const char *n2);
@@ -166,6 +164,4 @@ unsigned get_ratio(upx_uint64_t u_len, upx_uint64_t c_len);
bool set_method_name(char *buf, size_t size, int method, int level);
void center_string(char *buf, size_t size, const char *s);
#endif /* already included */
/* vim:set ts=4 sw=4 et: */