MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / l_randomizePivot

Function l_randomizePivot

extlibs/lua/src/ltablib.c:244–254  ·  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

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

Callers 1

auxsortFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected