A few more simple changes & fixes.

This commit is contained in:
Wayne Davison committed 2020-06-26 13:19:07 -07:00
1 parent b1a8b09c21
commit d07c2992d1
5 files changed
+11 -11

No files matched your search

+1 -1
View File
@@ -105,7 +105,7 @@ free_stat_x(stat_x *sx_p)
static inline char *my_strdup(const char *str, const char *file, int line)
{
int len = strlen(str)+1;
char *buf = _my_alloc(do_malloc, len, 1, file, line);
char *buf = my_alloc(do_malloc, len, 1, file, line);
memcpy(buf, str, len);
return buf;
}
+1 -1
View File
@@ -1301,7 +1301,7 @@ static ssize_t parse_size_arg(char *size_arg, char def_suf, const char *opt_name
while (reps--)
size *= mult;
size *= atof(size_arg);
if ((*arg == '+' || *arg == '-') && arg[1] == '1')
if ((*arg == '+' || *arg == '-') && arg[1] == '1' && arg != size_arg)
size += atoi(arg), arg += 2;
if (*arg)
goto failure;
+1 -1
View File
@@ -1740,7 +1740,7 @@ your home directory (remove the '=' for that).
multiples of 1024. If you use a two-letter suffix that ends with a "B"
(e.g. "kb") then you get units that are multiples of 1000.
Finally, if the value ends with either "+1" or "-1", it will be offset by
Finally, if the string ends with either "+1" or "-1", it will be offset by
one byte in the indicated direction. The largest possible value is
`8192P-1`.
+6 -6
View File
@@ -1265,13 +1265,13 @@ extern int errno;
extern char *do_malloc;
/* Convenient wrappers for malloc and realloc. Use them. */
#define new(type) ((type*)_my_alloc(do_malloc, 1, sizeof (type), __FILE__, __LINE__))
#define new0(type) ((type*)_my_alloc(NULL, 1, sizeof (type), __FILE__, __LINE__))
#define realloc_buf(ptr, num) _my_alloc((ptr), (num), 1, __FILE__, __LINE__)
#define new(type) ((type*)my_alloc(do_malloc, sizeof (type), 1, __FILE__, __LINE__))
#define new0(type) ((type*)my_alloc(NULL, sizeof (type), 1, __FILE__, __LINE__))
#define realloc_buf(ptr, num) my_alloc((ptr), (num), 1, __FILE__, __LINE__)
#define new_array(type, num) ((type*)_my_alloc(do_malloc, (num), sizeof (type), __FILE__, __LINE__))
#define new_array0(type, num) ((type*)_my_alloc(NULL, (num), sizeof (type), __FILE__, __LINE__))
#define realloc_array(ptr, type, num) ((type*)_my_alloc((ptr), (num), sizeof (type), __FILE__, __LINE__))
#define new_array(type, num) ((type*)my_alloc(do_malloc, (num), sizeof (type), __FILE__, __LINE__))
#define new_array0(type, num) ((type*)my_alloc(NULL, (num), sizeof (type), __FILE__, __LINE__))
#define realloc_array(ptr, type, num) ((type*)my_alloc((ptr), (num), sizeof (type), __FILE__, __LINE__))
#define strdup(s) my_strdup(s, __FILE__, __LINE__)
+2 -2
View File
@@ -71,7 +71,7 @@ int msleep(int t)
return True;
}
/* We convert a num manually because need %lld precision, and that's not a portable sprintf() escape. */
/* Convert a num manually because the needed %lld precision is not a portable sprintf() escape. */
char *num_to_byte_string(ssize_t num)
{
char buf[128], *s = buf + sizeof buf - 1;
@@ -84,7 +84,7 @@ char *num_to_byte_string(ssize_t num)
return strdup(s);
}
void *_my_alloc(void *ptr, size_t num, size_t size, const char *file, int line)
void *my_alloc(void *ptr, size_t num, size_t size, const char *file, int line)
{
if (num >= max_alloc/size) {
if (!file)