21 #include "my_global.h"
36 #include <arpa/inet.h>
50 DBUG_ASSERT(size > 0);
55 #ifdef HAVE_POSIX_MEMALIGN
57 if (unlikely(posix_memalign(& ptr, PFS_ALIGNEMENT, size)))
62 ptr= memalign(PFS_ALIGNEMENT, size);
63 if (unlikely(ptr == NULL))
66 #ifdef HAVE_ALIGNED_MALLOC
68 ptr= _aligned_malloc(size, PFS_ALIGNEMENT);
69 if (unlikely(ptr == NULL))
72 #error "Missing implementation for PFS_ALIGNENT"
79 if (unlikely(ptr == NULL))
84 if (flags & MY_ZEROFILL)
94 #ifdef HAVE_POSIX_MEMALIGN
102 #ifdef HAVE_ALIGNED_MALLOC
113 void pfs_print_error(
const char *format, ...)
116 va_start(args, format);
123 vfprintf(stderr, format, args);
133 const struct sockaddr_storage *src_addr,
137 DBUG_ASSERT(src_addr);
140 memset(host, 0, host_len);
143 switch (src_addr->ss_family)
147 if (host_len < INET_ADDRSTRLEN+1)
149 struct sockaddr_in *sa4= (
struct sockaddr_in *)(src_addr);
152 getnameinfo((
struct sockaddr *)sa4,
sizeof(
struct sockaddr_in),
153 host, host_len, NULL, 0, NI_NUMERICHOST);
155 inet_ntop(AF_INET, &(sa4->sin_addr), host, INET_ADDRSTRLEN);
157 *port= ntohs(sa4->sin_port);
164 if (host_len < INET6_ADDRSTRLEN+1)
166 struct sockaddr_in6 *sa6= (
struct sockaddr_in6 *)(src_addr);
169 getnameinfo((
struct sockaddr *)sa6,
sizeof(
struct sockaddr_in6),
170 host, host_len, NULL, 0, NI_NUMERICHOST);
172 inet_ntop(AF_INET6, &(sa6->sin6_addr), host, INET6_ADDRSTRLEN);
174 *port= ntohs(sa6->sin6_port);
184 return (strlen((
const char*)host));