MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / l_randomizePivot

Function l_randomizePivot

lib/lua/src/ltablib.c:246–256  ·  view source on GitHub ↗

** Use 'time' and 'clock' as sources of "randomness". Because we don't ** know the types 'clock_t' and 'time_t', we cannot cast them to ** anything without risking overflows. A safe way to use their values ** is to copy them to an array of a known type and use the array values. */

Source from the content-addressed store, hash-verified

244** is to copy them to an array of a known type and use the array values.
245*/
246static unsigned int l_randomizePivot (void) {
247 clock_t c = clock();
248 time_t t = time(NULL);
249 unsigned int buff[sof(c) + sof(t)];
250 unsigned int i, rnd = 0;
251 memcpy(buff, &c, sof(c) * sizeof(unsigned int));
252 memcpy(buff + sof(c), &t, sof(t) * sizeof(unsigned int));
253 for (i = 0; i < sof(buff); i++)
254 rnd += buff[i];
255 return rnd;
256}
257
258#endif /* } */
259

Callers 1

auxsortFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected