GRU - Generic Reusable Utilities
Loading...
Searching...
No Matches
Functions
gru_alt.h File Reference
#include <string.h>
#include "common/gru_base.h"
#include "common/gru_portable.h"

Go to the source code of this file.

Functions

gru_export size_t strlcpy (char *gru_restrict dst, const char *gru_restrict src, size_t size)
 Very simple alternatives to some safer string variables. More...
 
gru_export size_t strlcat (char *gru_restrict dst, const char *gru_restrict src, size_t size)
 Poor man's implementation of strlcat. More...
 
gru_export char * strndup (const char *source, size_t limit)
 Poor man's implementation of strndup (duplicate a string) More...
 

Function Documentation

◆ strlcat()

gru_export size_t strlcat ( char *gru_restrict  dst,
const char *gru_restrict  src,
size_t  size 
)

Poor man's implementation of strlcat.

Parameters
dstdestination buffer
srcsource buffer
sizeamount of bytes to copy
Returns
The total length of the string they tried to create

◆ strlcpy()

gru_export size_t strlcpy ( char *gru_restrict  dst,
const char *gru_restrict  src,
size_t  size 
)

Very simple alternatives to some safer string variables.

Do not use unless libbsd or other more mature alternatives are not available Poor man's implementation of strlcpy (works just like strncpy, but copies size - 1)

Parameters
dstdestination buffer
srcsource buffer
sizeamount of bytes to copy
Returns
The amount of bytes copied

◆ strndup()

gru_export char * strndup ( const char *  source,
size_t  limit 
)

Poor man's implementation of strndup (duplicate a string)

Parameters
sourcesource string
limitmaximum number of bytes to copy