all: yet more minor updates
This commit is contained in:
+10
-14
@@ -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: */
|
||||
|
||||
Reference in New Issue
Block a user