Skip to content

Commit

Permalink
Fix some errors, when using with C++
Browse files Browse the repository at this point in the history
1. "restrict" keyword does not exist in C++
2. Use explicit cast from malloc to parameter
   type used by _nl_inet_ntop
  • Loading branch information
ievenbach committed Apr 24, 2024
1 parent 96ddcd9 commit 259b99b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/base/nl-base-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static inline bool _nl_memeq(const void *s1, const void *s2, size_t len)
return _nl_memcmp(s1, s2, len) == 0;
}

static inline void *_nl_memcpy(void *restrict dest, const void *restrict src,
static inline void *_nl_memcpy(void *dest, const void *src,
size_t n)
{
/* Workaround undefined behavior in memcpy() with NULL pointers. */
Expand Down Expand Up @@ -703,7 +703,7 @@ static inline char *_nl_inet_ntop(int addr_family, const void *addr, char *buf)
static inline char *_nl_inet_ntop_dup(int addr_family, const void *addr)
{
return (char *)_nl_inet_ntop(addr_family, addr,
malloc((addr_family == AF_INET) ?
(char*)malloc((addr_family == AF_INET) ?
INET_ADDRSTRLEN :
INET6_ADDRSTRLEN));
}
Expand Down

0 comments on commit 259b99b

Please sign in to comment.