MCPcopy Create free account
hub / github.com/antirez/ds4 / random_bytes

Function random_bytes

ds4_server.c:89–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87 return p;
88}
89
90static char *xstrdup(const char *s) {
91 size_t n = strlen(s);
92 char *p = xmalloc(n + 1);
93 memcpy(p, s, n + 1);
94 return p;
95}
96
97static bool random_bytes(void *dst, size_t len) {
98 unsigned char *p = dst;
99 int fd = open("/dev/urandom", O_RDONLY);
100 if (fd < 0) return false;
101 while (len) {
102 ssize_t n = read(fd, p, len);
103 if (n < 0 && errno == EINTR) continue;
104 if (n <= 0) {
105 close(fd);
106 return false;
107 }
108 p += (size_t)n;

Callers 2

random_tool_idFunction · 0.85
responses_random_idFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected