Movatterモバイル変換


[0]ホーム

URL:


Skip to content

types.h

Functions

Name
void *XMALLOC(size_t n, void * heap, int type)
This is not actually a function, but rather a preprocessor macro, which allows the user to substitute in their own malloc, realloc, and free functions in place of the standard C memory functions. To use external memory functions, define XMALLOC_USER. This will cause the memory functions to be replaced by external functions of the form: extern voidXMALLOC(size_t n, void heap, int type); extern void _XREALLOC(voidp, size_t n, void_ heap, int type); extern void XFREE(voidp, void heap, int type); To use the basic C memory functions in place of wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free, define NO_WOLFSSL_MEMORY. This will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s))) #define XFREE(p, h, t) {void xp = (p); if((xp)) free((xp));} #define XREALLOC(p, n, h, t) realloc((p), (n)) If none of these options are selected, the system will default to use the wolfSSL memory functions. A user can set custom memory functions through callback hooks, (see wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free). This option will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s))) #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));} #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
void *XREALLOC(void * p, size_t n, void * heap, int type)
This is not actually a function, but rather a preprocessor macro, which allows the user to substitute in their own malloc, realloc, and free functions in place of the standard C memory functions. To use external memory functions, define XMALLOC_USER. This will cause the memory functions to be replaced by external functions of the form: extern voidXMALLOC(size_t n, void heap, int type); extern void _XREALLOC(voidp, size_t n, void_ heap, int type); extern void XFREE(voidp, void heap, int type); To use the basic C memory functions in place of wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free, define NO_WOLFSSL_MEMORY. This will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s))) #define XFREE(p, h, t) {void xp = (p); if((xp)) free((xp));} #define XREALLOC(p, n, h, t) realloc((p), (n)) If none of these options are selected, the system will default to use the wolfSSL memory functions. A user can set custom memory functions through callback hooks, (see wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free). This option will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s))) #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));} #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
voidXFREE(void * p, void * heap, int type)
This is not actually a function, but rather a preprocessor macro, which allows the user to substitute in their own malloc, realloc, and free functions in place of the standard C memory functions. To use external memory functions, define XMALLOC_USER. This will cause the memory functions to be replaced by external functions of the form: extern voidXMALLOC(size_t n, void heap, int type); extern void _XREALLOC(voidp, size_t n, void_ heap, int type); extern void XFREE(voidp, void heap, int type); To use the basic C memory functions in place of wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free, define NO_WOLFSSL_MEMORY. This will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s))) #define XFREE(p, h, t) {void xp = (p); if((xp)) free((xp));} #define XREALLOC(p, n, h, t) realloc((p), (n)) If none of these options are selected, the system will default to use the wolfSSL memory functions. A user can set custom memory functions through callback hooks, (see wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free). This option will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s))) #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));} #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
word32CheckRunTimeSettings(void )
This function checks the compile time class settings. It is important when a user is using a wolfCrypt library independently, as the settings must match between libraries for math to work correctly. This check is defined as CheckCtcSettings(), which simply compares CheckRunTimeSettings and CTC_SETTINGS, returning 0 if there is a mismatch, or 1 if they match.
char *wc_strtok(char * str, const char * delim, char ** nextp)
Thread-safe string tokenization.
char *wc_strsep(char ** stringp, const char * delim)
Separates string by delimiter.
size_twc_strlcpy(char * dst, const char * src, size_t dstSize)
Safely copies string with size limit.
size_twc_strlcat(char * dst, const char * src, size_t dstSize)
Safely concatenates strings with size limit.
intwc_strcasecmp(const char * s1, const char * s2)
Case-insensitive string comparison.
intwc_strncasecmp(const char * s1, const char * s2, size_t n)
Case-insensitive string comparison with length limit.
intwolfSSL_NewThread(THREAD_TYPE * thread, THREAD_CB cb, void * arg)
Creates a new thread.
intwolfSSL_NewThreadNoJoin(THREAD_CB_NOJOIN cb, void * arg)
Creates a detached thread.
intwolfSSL_JoinThread(THREAD_TYPE thread)
Waits for thread to complete.
intwolfSSL_CondInit(COND_TYPE * cond)
Initializes condition variable.
intwolfSSL_CondFree(COND_TYPE * cond)
Frees condition variable.
intwolfSSL_CondSignal(COND_TYPE * cond)
Signals condition variable.
intwolfSSL_CondWait(COND_TYPE * cond)
Waits on condition variable.
intwolfSSL_CondStart(COND_TYPE * cond)
Starts condition variable.
intwolfSSL_CondEnd(COND_TYPE * cond)
Ends condition variable.

Functions Documentation

function XMALLOC

void * XMALLOC(    size_t n,    void * heap,    int type)

This is not actually a function, but rather a preprocessor macro, which allows the user to substitute in their own malloc, realloc, and free functions in place of the standard C memory functions. To use external memory functions, define XMALLOC_USER. This will cause the memory functions to be replaced by external functions of the form: extern voidXMALLOC(size_t n, void heap, int type); extern void _XREALLOC(voidp, size_t n, void_ heap, int type); extern void XFREE(voidp, void heap, int type); To use the basic C memory functions in place of wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free, define NO_WOLFSSL_MEMORY. This will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s))) #define XFREE(p, h, t) {void xp = (p); if((xp)) free((xp));} #define XREALLOC(p, n, h, t) realloc((p), (n)) If none of these options are selected, the system will default to use the wolfSSL memory functions. A user can set custom memory functions through callback hooks, (see wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free). This option will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s))) #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));} #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))

Parameters:

See:

Return:

  • pointer Return a pointer to allocated memory on success
  • NULL on failure

Example

int* tenInts = XMALLOC(sizeof(int)*10, NULL, DYNAMIC_TYPE_TMP_BUFFER);if (tenInts == NULL) {    // error allocating space    return MEMORY_E;}

function XREALLOC

void * XREALLOC(    void * p,    size_t n,    void * heap,    int type)

This is not actually a function, but rather a preprocessor macro, which allows the user to substitute in their own malloc, realloc, and free functions in place of the standard C memory functions. To use external memory functions, define XMALLOC_USER. This will cause the memory functions to be replaced by external functions of the form: extern voidXMALLOC(size_t n, void heap, int type); extern void _XREALLOC(voidp, size_t n, void_ heap, int type); extern void XFREE(voidp, void heap, int type); To use the basic C memory functions in place of wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free, define NO_WOLFSSL_MEMORY. This will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s))) #define XFREE(p, h, t) {void xp = (p); if((xp)) free((xp));} #define XREALLOC(p, n, h, t) realloc((p), (n)) If none of these options are selected, the system will default to use the wolfSSL memory functions. A user can set custom memory functions through callback hooks, (see wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free). This option will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s))) #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));} #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))

Parameters:

  • p pointer to the address to reallocate
  • n size of memory to allocate
  • h (used by custom XREALLOC function) pointer to the heap to use
  • t memory allocation types for user hints. See enum intypes.h

See:

Return:

  • Return a pointer to allocated memory on success
  • NULL on failure

Example

int* tenInts = (int*)XMALLOC(sizeof(int)*10, NULL, DYNAMIC_TYPE_TMP_BUFFER);int* twentyInts = (int*)XREALLOC(tenInts, sizeof(int)*20, NULL,    DYNAMIC_TYPE_TMP_BUFFER);

function XFREE

void XFREE(    void * p,    void * heap,    int type)

This is not actually a function, but rather a preprocessor macro, which allows the user to substitute in their own malloc, realloc, and free functions in place of the standard C memory functions. To use external memory functions, define XMALLOC_USER. This will cause the memory functions to be replaced by external functions of the form: extern voidXMALLOC(size_t n, void heap, int type); extern void _XREALLOC(voidp, size_t n, void_ heap, int type); extern void XFREE(voidp, void heap, int type); To use the basic C memory functions in place of wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free, define NO_WOLFSSL_MEMORY. This will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s))) #define XFREE(p, h, t) {void xp = (p); if((xp)) free((xp));} #define XREALLOC(p, n, h, t) realloc((p), (n)) If none of these options are selected, the system will default to use the wolfSSL memory functions. A user can set custom memory functions through callback hooks, (see wolfSSL_Malloc, wolfSSL_Realloc, wolfSSL_Free). This option will replace the memory functions with: #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s))) #define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));} #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))

Parameters:

  • p pointer to the address to free
  • h (used by custom XFREE function) pointer to the heap to use
  • t memory allocation types for user hints. See enum intypes.h

See:

Return: none No returns.

Example

int* tenInts = XMALLOC(sizeof(int) * 10, NULL, DYNAMIC_TYPE_TMP_BUFFER);if (tenInts == NULL) {    // error allocating space    return MEMORY_E;}

function CheckRunTimeSettings

word32 CheckRunTimeSettings(    void )

This function checks the compile time class settings. It is important when a user is using a wolfCrypt library independently, as the settings must match between libraries for math to work correctly. This check is defined as CheckCtcSettings(), which simply compares CheckRunTimeSettings and CTC_SETTINGS, returning 0 if there is a mismatch, or 1 if they match.

Parameters:

  • none No Parameters.

See:CheckRunTimeFastMath

Return: settings Returns the runtime CTC_SETTINGS (Compile Time Settings)

Example

if (CheckCtcSettings() != 1) {    return err_sys("Build vs. runtime math mismatch\n");}// This is converted by the preprocessor to:// if ( (CheckCtcSettings() == CTC_SETTINGS) != 1) {// and will compare whether the compile time class settings// match the current settings

function wc_strtok

char * wc_strtok(    char * str,    const char * delim,    char ** nextp)

Thread-safe string tokenization.

Parameters:

  • str String to tokenize (NULL for continuation)
  • delim Delimiter characters
  • nextp Pointer to save position

See:wc_strsep

Return: Pointer to next token or NULL

Example

char str[] = "one,two,three";char* saveptr;char* token = wc_strtok(str, ",", &saveptr);

function wc_strsep

char * wc_strsep(    char ** stringp,    const char * delim)

Separates string by delimiter.

Parameters:

  • stringp Pointer to string pointer
  • delim Delimiter characters

See:wc_strtok

Return: Pointer to token or NULL

Example

char str[] = "one,two,three";char* ptr = str;char* token = wc_strsep(&ptr, ",");

function wc_strlcpy

size_t wc_strlcpy(    char * dst,    const char * src,    size_t dstSize)

Safely copies string with size limit.

Parameters:

  • dst Destination buffer
  • src Source string
  • dstSize Destination buffer size

See:wc_strlcat

Return: Length of source string

Example

char dst[10];size_t len = wc_strlcpy(dst, "hello", sizeof(dst));

function wc_strlcat

size_t wc_strlcat(    char * dst,    const char * src,    size_t dstSize)

Safely concatenates strings with size limit.

Parameters:

  • dst Destination buffer
  • src Source string
  • dstSize Destination buffer size

See:wc_strlcpy

Return: Total length attempted

Example

char dst[20] = "hello";size_t len = wc_strlcat(dst, " world", sizeof(dst));

function wc_strcasecmp

int wc_strcasecmp(    const char * s1,    const char * s2)

Case-insensitive string comparison.

Parameters:

  • s1 First string
  • s2 Second string

See:wc_strncasecmp

Return: 0 if equal, non-zero otherwise

Example

if (wc_strcasecmp("Hello", "hello") == 0) {    // strings are equal}

function wc_strncasecmp

int wc_strncasecmp(    const char * s1,    const char * s2,    size_t n)

Case-insensitive string comparison with length limit.

Parameters:

  • s1 First string
  • s2 Second string
  • n Maximum characters to compare

See:wc_strcasecmp

Return: 0 if equal, non-zero otherwise

Example

if (wc_strncasecmp("Hello", "hello", 5) == 0) {    // strings are equal}

function wolfSSL_NewThread

int wolfSSL_NewThread(    THREAD_TYPE * thread,    THREAD_CB cb,    void * arg)

Creates a new thread.

Parameters:

  • thread Thread handle pointer
  • cb Thread callback function
  • arg Argument to pass to callback

See:wolfSSL_JoinThread

Return:

  • 0 on success
  • negative on error

Example

THREAD_TYPE thread;int ret = wolfSSL_NewThread(&thread, myCallback, NULL);

function wolfSSL_NewThreadNoJoin

int wolfSSL_NewThreadNoJoin(    THREAD_CB_NOJOIN cb,    void * arg)

Creates a detached thread.

Parameters:

  • cb Thread callback function
  • arg Argument to pass to callback

See:wolfSSL_NewThread

Return:

  • 0 on success
  • negative on error

Example

int ret = wolfSSL_NewThreadNoJoin(myCallback, NULL);

function wolfSSL_JoinThread

int wolfSSL_JoinThread(    THREAD_TYPE thread)

Waits for thread to complete.

Parameters:

  • thread Thread handle

See:wolfSSL_NewThread

Return:

  • 0 on success
  • negative on error

Example

THREAD_TYPE thread;wolfSSL_NewThread(&thread, myCallback, NULL);int ret = wolfSSL_JoinThread(thread);

function wolfSSL_CondInit

int wolfSSL_CondInit(    COND_TYPE * cond)

Initializes condition variable.

Parameters:

  • cond Condition variable pointer

See:wolfSSL_CondFree

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;int ret = wolfSSL_CondInit(&cond);

function wolfSSL_CondFree

int wolfSSL_CondFree(    COND_TYPE * cond)

Frees condition variable.

Parameters:

  • cond Condition variable pointer

See:wolfSSL_CondInit

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;wolfSSL_CondInit(&cond);int ret = wolfSSL_CondFree(&cond);

function wolfSSL_CondSignal

int wolfSSL_CondSignal(    COND_TYPE * cond)

Signals condition variable.

Parameters:

  • cond Condition variable pointer

See:wolfSSL_CondWait

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;int ret = wolfSSL_CondSignal(&cond);

function wolfSSL_CondWait

int wolfSSL_CondWait(    COND_TYPE * cond)

Waits on condition variable.

Parameters:

  • cond Condition variable pointer

See:wolfSSL_CondSignal

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;int ret = wolfSSL_CondWait(&cond);

function wolfSSL_CondStart

int wolfSSL_CondStart(    COND_TYPE * cond)

Starts condition variable.

Parameters:

  • cond Condition variable pointer

See:wolfSSL_CondEnd

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;int ret = wolfSSL_CondStart(&cond);

function wolfSSL_CondEnd

int wolfSSL_CondEnd(    COND_TYPE * cond)

Ends condition variable.

Parameters:

  • cond Condition variable pointer

See:wolfSSL_CondStart

Return:

  • 0 on success
  • negative on error

Example

COND_TYPE cond;wolfSSL_CondStart(&cond);int ret = wolfSSL_CondEnd(&cond);

Source code

void* XMALLOC(size_t n, void* heap, int type);void* XREALLOC(void *p, size_t n, void* heap, int type);void XFREE(void *p, void* heap, int type);word32 CheckRunTimeSettings(void);char* wc_strtok(char *str, const char *delim, char **nextp);char* wc_strsep(char **stringp, const char *delim);size_t wc_strlcpy(char *dst, const char *src, size_t dstSize);size_t wc_strlcat(char *dst, const char *src, size_t dstSize);int wc_strcasecmp(const char *s1, const char *s2);int wc_strncasecmp(const char *s1, const char *s2, size_t n);int wolfSSL_NewThread(THREAD_TYPE* thread, THREAD_CB cb, void* arg);int wolfSSL_NewThreadNoJoin(THREAD_CB_NOJOIN cb, void* arg);int wolfSSL_JoinThread(THREAD_TYPE thread);int wolfSSL_CondInit(COND_TYPE* cond);int wolfSSL_CondFree(COND_TYPE* cond);int wolfSSL_CondSignal(COND_TYPE* cond);int wolfSSL_CondWait(COND_TYPE* cond);int wolfSSL_CondStart(COND_TYPE* cond);int wolfSSL_CondEnd(COND_TYPE* cond);

Updated on 2026-02-20 at 02:00:33 +0000


[8]ページ先頭

©2009-2026 Movatter.jp