Modify the lower level memory allocation routines to take size_t
We've been using int for the size for a long time, it's about time... Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
26
crypto/mem.c
26
crypto/mem.c
@@ -107,9 +107,9 @@ static void (*free_secure_func)(void *) = free;
|
|||||||
/* XXX use correct function pointer types */
|
/* XXX use correct function pointer types */
|
||||||
#ifdef CRYPTO_MDEBUG
|
#ifdef CRYPTO_MDEBUG
|
||||||
/* use default functions from mem_dbg.c */
|
/* use default functions from mem_dbg.c */
|
||||||
static void (*malloc_debug_func) (void *, int, const char *, int, int)
|
static void (*malloc_debug_func) (void *, size_t, const char *, int, int)
|
||||||
= CRYPTO_dbg_malloc;
|
= CRYPTO_dbg_malloc;
|
||||||
static void (*realloc_debug_func) (void *, void *, int, const char *, int,
|
static void (*realloc_debug_func) (void *, void *, size_t, const char *, int,
|
||||||
int)
|
int)
|
||||||
= CRYPTO_dbg_realloc;
|
= CRYPTO_dbg_realloc;
|
||||||
static void (*free_debug_func) (void *, int) = CRYPTO_dbg_free;
|
static void (*free_debug_func) (void *, int) = CRYPTO_dbg_free;
|
||||||
@@ -197,9 +197,9 @@ int CRYPTO_set_secure_mem_ex_functions(void *(*m)(size_t, const char *, int),
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CRYPTO_set_mem_debug_functions(void (*m)
|
int CRYPTO_set_mem_debug_functions(void (*m) (void *, size_t,
|
||||||
(void *, int, const char *, int, int),
|
const char *, int, int),
|
||||||
void (*r) (void *, void *, int,
|
void (*r) (void *, void *, size_t,
|
||||||
const char *, int, int),
|
const char *, int, int),
|
||||||
void (*f) (void *, int), void (*so) (long),
|
void (*f) (void *, int), void (*so) (long),
|
||||||
long (*go) (void))
|
long (*go) (void))
|
||||||
@@ -257,9 +257,9 @@ void CRYPTO_get_secure_mem_ex_functions(void *(**m)(size_t,const char *,int),
|
|||||||
*f=free_secure_func;
|
*f=free_secure_func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRYPTO_get_mem_debug_functions(void (**m)
|
void CRYPTO_get_mem_debug_functions(void (**m) (void *, size_t,
|
||||||
(void *, int, const char *, int, int),
|
const char *, int, int),
|
||||||
void (**r) (void *, void *, int,
|
void (**r) (void *, void *, size_t,
|
||||||
const char *, int, int),
|
const char *, int, int),
|
||||||
void (**f) (void *, int),
|
void (**f) (void *, int),
|
||||||
void (**so) (long), long (**go) (void))
|
void (**so) (long), long (**go) (void))
|
||||||
@@ -276,7 +276,7 @@ void CRYPTO_get_mem_debug_functions(void (**m)
|
|||||||
*go = get_debug_options_func;
|
*go = get_debug_options_func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *CRYPTO_malloc(int num, const char *file, int line)
|
void *CRYPTO_malloc(size_t num, const char *file, int line)
|
||||||
{
|
{
|
||||||
void *ret = NULL;
|
void *ret = NULL;
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ void *CRYPTO_malloc(int num, const char *file, int line)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *CRYPTO_zalloc(int num, const char *file, int line)
|
void *CRYPTO_zalloc(size_t num, const char *file, int line)
|
||||||
{
|
{
|
||||||
void *ret = CRYPTO_malloc(num, file, line);
|
void *ret = CRYPTO_malloc(num, file, line);
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ void *CRYPTO_zalloc(int num, const char *file, int line)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *CRYPTO_realloc(void *str, int num, const char *file, int line)
|
void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
|
||||||
{
|
{
|
||||||
void *ret = NULL;
|
void *ret = NULL;
|
||||||
|
|
||||||
@@ -337,8 +337,8 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
|
void *CRYPTO_realloc_clean(void *str, size_t old_len, size_t num,
|
||||||
int line)
|
const char *file, int line)
|
||||||
{
|
{
|
||||||
void *ret = NULL;
|
void *ret = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -451,7 +451,7 @@ int CRYPTO_remove_all_info(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long break_order_num = 0;
|
static unsigned long break_order_num = 0;
|
||||||
void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
|
void CRYPTO_dbg_malloc(void *addr, size_t num, const char *file, int line,
|
||||||
int before_p)
|
int before_p)
|
||||||
{
|
{
|
||||||
MEM *m, *mm;
|
MEM *m, *mm;
|
||||||
@@ -555,7 +555,7 @@ void CRYPTO_dbg_free(void *addr, int before_p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
|
void CRYPTO_dbg_realloc(void *addr1, void *addr2, size_t num,
|
||||||
const char *file, int line, int before_p)
|
const char *file, int line, int before_p)
|
||||||
{
|
{
|
||||||
MEM m, *mp;
|
MEM m, *mp;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ int CRYPTO_secure_malloc_initialized()
|
|||||||
#endif /* IMPLEMENTED */
|
#endif /* IMPLEMENTED */
|
||||||
}
|
}
|
||||||
|
|
||||||
void *CRYPTO_secure_malloc(int num, const char *file, int line)
|
void *CRYPTO_secure_malloc(size_t num, const char *file, int line)
|
||||||
{
|
{
|
||||||
#ifdef IMPLEMENTED
|
#ifdef IMPLEMENTED
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|||||||
@@ -453,9 +453,9 @@ int CRYPTO_set_mem_functions(void *(*m) (size_t), void *(*r) (void *, size_t),
|
|||||||
int CRYPTO_set_mem_ex_functions(void *(*m) (size_t, const char *, int),
|
int CRYPTO_set_mem_ex_functions(void *(*m) (size_t, const char *, int),
|
||||||
void *(*r) (void *, size_t, const char *,
|
void *(*r) (void *, size_t, const char *,
|
||||||
int), void (*f) (void *));
|
int), void (*f) (void *));
|
||||||
int CRYPTO_set_mem_debug_functions(void (*m)
|
int CRYPTO_set_mem_debug_functions(void (*m) (void *, size_t,
|
||||||
(void *, int, const char *, int, int),
|
const char *, int, int),
|
||||||
void (*r) (void *, void *, int,
|
void (*r) (void *, void *, size_t,
|
||||||
const char *, int, int),
|
const char *, int, int),
|
||||||
void (*f) (void *, int), void (*so) (long),
|
void (*f) (void *, int), void (*so) (long),
|
||||||
long (*go) (void));
|
long (*go) (void));
|
||||||
@@ -465,23 +465,23 @@ void CRYPTO_get_mem_functions(void *(**m) (size_t),
|
|||||||
void CRYPTO_get_mem_ex_functions(void *(**m) (size_t, const char *, int),
|
void CRYPTO_get_mem_ex_functions(void *(**m) (size_t, const char *, int),
|
||||||
void *(**r) (void *, size_t, const char *,
|
void *(**r) (void *, size_t, const char *,
|
||||||
int), void (**f) (void *));
|
int), void (**f) (void *));
|
||||||
void CRYPTO_get_mem_debug_functions(void (**m)
|
void CRYPTO_get_mem_debug_functions(void (**m) (void *, size_t,
|
||||||
(void *, int, const char *, int, int),
|
const char *, int, int),
|
||||||
void (**r) (void *, void *, int,
|
void (**r) (void *, void *, size_t,
|
||||||
const char *, int, int),
|
const char *, int, int),
|
||||||
void (**f) (void *, int),
|
void (**f) (void *, int),
|
||||||
void (**so) (long), long (**go) (void));
|
void (**so) (long), long (**go) (void));
|
||||||
|
|
||||||
void *CRYPTO_malloc(int num, const char *file, int line);
|
void *CRYPTO_malloc(size_t num, const char *file, int line);
|
||||||
void *CRYPTO_zalloc(int num, const char *file, int line);
|
void *CRYPTO_zalloc(size_t num, const char *file, int line);
|
||||||
void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line);
|
void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line);
|
||||||
char *CRYPTO_strdup(const char *str, const char *file, int line);
|
char *CRYPTO_strdup(const char *str, const char *file, int line);
|
||||||
char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line);
|
char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line);
|
||||||
void CRYPTO_free(void *ptr);
|
void CRYPTO_free(void *ptr);
|
||||||
void CRYPTO_clear_free(void *ptr, size_t num);
|
void CRYPTO_clear_free(void *ptr, size_t num);
|
||||||
void *CRYPTO_realloc(void *addr, int num, const char *file, int line);
|
void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line);
|
||||||
void *CRYPTO_realloc_clean(void *addr, int old_num, int num, const char *file,
|
void *CRYPTO_realloc_clean(void *addr, size_t old_num, size_t num,
|
||||||
int line);
|
const char *file, int line);
|
||||||
|
|
||||||
# define OPENSSL_secure_malloc(num) \
|
# define OPENSSL_secure_malloc(num) \
|
||||||
CRYPTO_secure_malloc((int)num,__FILE__,__LINE__)
|
CRYPTO_secure_malloc((int)num,__FILE__,__LINE__)
|
||||||
@@ -490,7 +490,7 @@ void *CRYPTO_realloc_clean(void *addr, int old_num, int num, const char *file,
|
|||||||
|
|
||||||
int CRYPTO_secure_malloc_init(size_t sz, int minsize);
|
int CRYPTO_secure_malloc_init(size_t sz, int minsize);
|
||||||
void CRYPTO_secure_malloc_done(void);
|
void CRYPTO_secure_malloc_done(void);
|
||||||
void *CRYPTO_secure_malloc(int num, const char *file, int line);
|
void *CRYPTO_secure_malloc(size_t num, const char *file, int line);
|
||||||
void CRYPTO_secure_free(void *ptr);
|
void CRYPTO_secure_free(void *ptr);
|
||||||
int CRYPTO_secure_allocated(const void *ptr);
|
int CRYPTO_secure_allocated(const void *ptr);
|
||||||
int CRYPTO_secure_malloc_initialized(void);
|
int CRYPTO_secure_malloc_initialized(void);
|
||||||
@@ -523,9 +523,9 @@ int CRYPTO_remove_all_info(void);
|
|||||||
* 0: called before the actual memory allocation has taken place
|
* 0: called before the actual memory allocation has taken place
|
||||||
* 1: called after the actual memory allocation has taken place
|
* 1: called after the actual memory allocation has taken place
|
||||||
*/
|
*/
|
||||||
void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
|
void CRYPTO_dbg_malloc(void *addr, size_t num, const char *file, int line,
|
||||||
int before_p);
|
int before_p);
|
||||||
void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file,
|
void CRYPTO_dbg_realloc(void *addr1, void *addr2, size_t num, const char *file,
|
||||||
int line, int before_p);
|
int line, int before_p);
|
||||||
void CRYPTO_dbg_free(void *addr, int before_p);
|
void CRYPTO_dbg_free(void *addr, int before_p);
|
||||||
/*-
|
/*-
|
||||||
@@ -544,8 +544,8 @@ long CRYPTO_dbg_get_options(void);
|
|||||||
void CRYPTO_mem_leaks_fp(FILE *);
|
void CRYPTO_mem_leaks_fp(FILE *);
|
||||||
# endif
|
# endif
|
||||||
void CRYPTO_mem_leaks(struct bio_st *bio);
|
void CRYPTO_mem_leaks(struct bio_st *bio);
|
||||||
/* unsigned long order, char *file, int line, int num_bytes, char *addr */
|
/* unsigned long order, char *file, int line, size_t num_bytes, char *addr */
|
||||||
typedef void *CRYPTO_MEM_LEAK_CB (unsigned long, const char *, int, int,
|
typedef void *CRYPTO_MEM_LEAK_CB (unsigned long, const char *, int, size_t,
|
||||||
void *);
|
void *);
|
||||||
void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
|
void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user