mirror of
https://github.com/curl/curl.git
synced 2026-04-20 14:11:16 +03:00
mbedtls: replace macro constant with CURL_ARRAYSIZE()
Also move from `int` to `size_t` for index variables. Closes #19762
This commit is contained in:
parent
985f86f0be
commit
c3add7130d
2 changed files with 12 additions and 15 deletions
|
|
@ -37,17 +37,14 @@
|
|||
|
||||
#include "mbedtls_threadlock.h"
|
||||
|
||||
/* number of thread locks */
|
||||
#define NUMT 2
|
||||
|
||||
/* This array stores the mutexes available to Mbedtls */
|
||||
static MBEDTLS_MUTEX_T mutex_buf[NUMT];
|
||||
/* This array stores the mutexes available to mbedTLS */
|
||||
static MBEDTLS_MUTEX_T mutex_buf[2];
|
||||
|
||||
int Curl_mbedtlsthreadlock_thread_setup(void)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < NUMT; i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(mutex_buf); i++) {
|
||||
#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
|
||||
if(pthread_mutex_init(&mutex_buf[i], NULL))
|
||||
return 0; /* pthread_mutex_init failed */
|
||||
|
|
@ -63,9 +60,9 @@ int Curl_mbedtlsthreadlock_thread_setup(void)
|
|||
|
||||
int Curl_mbedtlsthreadlock_thread_cleanup(void)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < NUMT; i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(mutex_buf); i++) {
|
||||
#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
|
||||
if(pthread_mutex_destroy(&mutex_buf[i]))
|
||||
return 0; /* pthread_mutex_destroy failed */
|
||||
|
|
@ -78,9 +75,9 @@ int Curl_mbedtlsthreadlock_thread_cleanup(void)
|
|||
return 1; /* OK */
|
||||
}
|
||||
|
||||
int Curl_mbedtlsthreadlock_lock_function(int n)
|
||||
int Curl_mbedtlsthreadlock_lock_function(size_t n)
|
||||
{
|
||||
if(n < NUMT) {
|
||||
if(n < CURL_ARRAYSIZE(mutex_buf)) {
|
||||
#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
|
||||
if(pthread_mutex_lock(&mutex_buf[n])) {
|
||||
DEBUGF(curl_mfprintf(stderr, "Error: "
|
||||
|
|
@ -98,9 +95,9 @@ int Curl_mbedtlsthreadlock_lock_function(int n)
|
|||
return 1; /* OK */
|
||||
}
|
||||
|
||||
int Curl_mbedtlsthreadlock_unlock_function(int n)
|
||||
int Curl_mbedtlsthreadlock_unlock_function(size_t n)
|
||||
{
|
||||
if(n < NUMT) {
|
||||
if(n < CURL_ARRAYSIZE(mutex_buf)) {
|
||||
#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
|
||||
if(pthread_mutex_unlock(&mutex_buf[n])) {
|
||||
DEBUGF(curl_mfprintf(stderr, "Error: "
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@
|
|||
|
||||
int Curl_mbedtlsthreadlock_thread_setup(void);
|
||||
int Curl_mbedtlsthreadlock_thread_cleanup(void);
|
||||
int Curl_mbedtlsthreadlock_lock_function(int n);
|
||||
int Curl_mbedtlsthreadlock_unlock_function(int n);
|
||||
int Curl_mbedtlsthreadlock_lock_function(size_t n);
|
||||
int Curl_mbedtlsthreadlock_unlock_function(size_t n);
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue