On Sun, 14 Oct 2001, Martin Sevior wrote: > On Fri, 12 Oct 2001, Matti Picus wrote: > > > Generating a unique int ID seems to be faulty in many places in AbiWord. > > The general method is to use the result from UT_rand() and hope that it is > > unique. > > Thanks to Pat Lam we have a great XP random number generator. This will on > average give you an identical random number one in 2^32 attempts. That's > approximately 1 in 4,000,000,000 attempts so we're pretty safe :-)
Yes, I used the random number generator from some library. If you get a collision with two numbers returned from UT_rand in a 32-bit address space, you've got other things to worry about; it's far more likely that you'll get hit by a truck, or your roof will spontaneously cave in. Keeping a counter introduces other problems too. You need to lock your counter (to prevent problems with concurrency), etc. And it won't make you do better. pat
