random.c 595 B

12345678910111213141516171819202122
  1. /*******************************************************************************
  2. * Copyright (c) 2017, Rockwell Automation, Inc.
  3. * All rights reserved.
  4. *
  5. ******************************************************************************/
  6. #include "random.h"
  7. #include <stdlib.h>
  8. Random *RandomNew(SetSeed set_seed,
  9. GetNextUInt32 get_next_uint32) {
  10. Random *random = malloc( sizeof(Random) );
  11. *random =
  12. (Random ) { .set_seed = set_seed, .get_next_uint32 = get_next_uint32 };
  13. return random;
  14. }
  15. void RandomDelete(Random **random) {
  16. free(*random);
  17. *random = NULL;
  18. }