提交 ff842856 编写于 作者: R Richard Levitte

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: NRich Salz <rsalz@openssl.org>
上级 33eaf4c2
......@@ -107,9 +107,9 @@ static void (*free_secure_func)(void *) = free;
/* XXX use correct function pointer types */
#ifdef CRYPTO_MDEBUG
/* 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;
static void (*realloc_debug_func) (void *, void *, int, const char *, int,
static void (*realloc_debug_func) (void *, void *, size_t, const char *, int,
int)
= CRYPTO_dbg_realloc;
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;
}
int CRYPTO_set_mem_debug_functions(void (*m)
(void *, int, const char *, int, int),
void (*r) (void *, void *, int,
int CRYPTO_set_mem_debug_functions(void (*m) (void *, size_t,
const char *, int, int),
void (*r) (void *, void *, size_t,
const char *, int, int),
void (*f) (void *, int), void (*so) (long),
long (*go) (void))
......@@ -245,7 +245,7 @@ void CRYPTO_get_secure_mem_functions(void *(**m)(size_t), void (**f)(void *))
malloc_secure_func : 0;
if (f != NULL)
*f=free_secure_func;
}
}
void CRYPTO_get_secure_mem_ex_functions(void *(**m)(size_t,const char *,int),
void (**f)(void *))
......@@ -257,9 +257,9 @@ void CRYPTO_get_secure_mem_ex_functions(void *(**m)(size_t,const char *,int),
*f=free_secure_func;
}
void CRYPTO_get_mem_debug_functions(void (**m)
(void *, int, const char *, int, int),
void (**r) (void *, void *, int,
void CRYPTO_get_mem_debug_functions(void (**m) (void *, size_t,
const char *, int, int),
void (**r) (void *, void *, size_t,
const char *, int, int),
void (**f) (void *, int),
void (**so) (long), long (**go) (void))
......@@ -276,7 +276,7 @@ void CRYPTO_get_mem_debug_functions(void (**m)
*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;
......@@ -309,7 +309,7 @@ void *CRYPTO_malloc(int num, const char *file, int line)
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);
......@@ -318,7 +318,7 @@ void *CRYPTO_zalloc(int num, const char *file, int line)
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;
......@@ -337,8 +337,8 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
return ret;
}
void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
int line)
void *CRYPTO_realloc_clean(void *str, size_t old_len, size_t num,
const char *file, int line)
{
void *ret = NULL;
......
......@@ -451,7 +451,7 @@ int CRYPTO_remove_all_info(void)
}
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)
{
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)
{
MEM m, *mp;
......
......@@ -89,7 +89,7 @@ int CRYPTO_secure_malloc_initialized()
#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
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),
void *(*r) (void *, size_t, const char *,
int), void (*f) (void *));
int CRYPTO_set_mem_debug_functions(void (*m)
(void *, int, const char *, int, int),
void (*r) (void *, void *, int,
int CRYPTO_set_mem_debug_functions(void (*m) (void *, size_t,
const char *, int, int),
void (*r) (void *, void *, size_t,
const char *, int, int),
void (*f) (void *, int), void (*so) (long),
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 *(**r) (void *, size_t, const char *,
int), void (**f) (void *));
void CRYPTO_get_mem_debug_functions(void (**m)
(void *, int, const char *, int, int),
void (**r) (void *, void *, int,
void CRYPTO_get_mem_debug_functions(void (**m) (void *, size_t,
const char *, int, int),
void (**r) (void *, void *, size_t,
const char *, int, int),
void (**f) (void *, int),
void (**so) (long), long (**go) (void));
void *CRYPTO_malloc(int num, const char *file, int line);
void *CRYPTO_zalloc(int num, const char *file, int line);
void *CRYPTO_malloc(size_t 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);
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);
void CRYPTO_free(void *ptr);
void CRYPTO_clear_free(void *ptr, size_t num);
void *CRYPTO_realloc(void *addr, int num, const char *file, int line);
void *CRYPTO_realloc_clean(void *addr, int old_num, 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, size_t old_num, size_t num,
const char *file, int line);
# define OPENSSL_secure_malloc(num) \
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);
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);
int CRYPTO_secure_allocated(const void *ptr);
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
* 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);
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);
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 *);
# endif
void CRYPTO_mem_leaks(struct bio_st *bio);
/* unsigned long order, char *file, int line, int num_bytes, char *addr */
typedef void *CRYPTO_MEM_LEAK_CB (unsigned long, const char *, int, int,
/* unsigned long order, char *file, int line, size_t num_bytes, char *addr */
typedef void *CRYPTO_MEM_LEAK_CB (unsigned long, const char *, int, size_t,
void *);
void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册