aboutsummaryrefslogtreecommitdiff
path: root/deps/ae/util.h
blob: 630c4ca763e4d9229c4697164b8149026d646587 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* util.h - minimal utilities needed by anet */
#ifndef __UTIL_H
#define __UTIL_H

#include <string.h>

/* Simple error buffer size */
#define ANET_ERR_LEN 256

/* Safe string copy - simplified version */
static inline size_t redis_strlcpy(char *dst, const char *src, size_t dsize) {
    size_t len = strlen(src);
    if (dsize > 0) {
        size_t copy_len = (len >= dsize) ? dsize - 1 : len;
        memcpy(dst, src, copy_len);
        dst[copy_len] = '\0';
    }
    return len;
}

#endif