< index
< 9. Pseudorandom number generator
< 9.3 Getting a random int from a byte array

=====================================
9.4 Destroying a generator
=====================================

To release ressources used by a generator, use those functions :
NB : do not delete the default random generator !

C++ : TCODRandom::~TCODRandom()
C   : void TCOD_random_delete(TCOD_random_t mersenne)
Py  : random_delete(mersenne)

ParameterDescription
mersenneIn the C version, the generator handler, returned by the initialization functions.

Example :

C++ : // create a generator
      TCODRandom *rnd = new TCODRandom();
      // use it 
      ...
      // destroy it
      delete rnd;
C   : /* create a generator */
      TCOD_random_t rnd = TCOD_random_new();
      /* use it */ 
      ...
      /* destroy it */
      TCOD_random_delete(rnd);
Py  : # create a generator 
      rnd = libtcod.random_new()
      # use it 
      ...
      # destroy it 
      libtcod.random_delete(rnd)

insert a comment