File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,17 @@ Random* RandomNew(SetSeed set_seed_function,
1313 GetNextUInt32 get_next_uint32_function ) {
1414 Random * random = malloc (sizeof (Random ));
1515 assert (random != NULL && "Failed to allocate Random struct" );
16+ RandomInit (random , set_seed_function , get_next_uint32_function );
17+ return random ;
18+ }
19+
20+ void RandomInit (Random * const random ,
21+ SetSeed set_seed_function ,
22+ GetNextUInt32 get_next_uint32_function ) {
23+ assert (random != NULL && "Cannot initialize NULL Random struct" );
1624 // The next line is fine, just false positive from cpplint due to formatting
1725 * random = (Random ){ .set_seed = set_seed_function ,
1826 .get_next_uint32 = get_next_uint32_function }; // NOLINT
19- return random ;
2027}
2128
2229void RandomDelete (Random * * random ) {
Original file line number Diff line number Diff line change @@ -25,9 +25,21 @@ typedef struct Random {
2525 get_next_uint32 ; ///< Function pointer to GetNextUInt32 function
2626} Random ;
2727
28+ /// @brief Creates a new Random object
29+ /// @param set_seed_function
30+ /// @param get_next_uint32_function
31+ /// @return Pointer to newly created Random object
2832Random * RandomNew (SetSeed set_seed_function ,
2933 GetNextUInt32 get_next_uint32_function );
3034
35+ /// @brief Initializes a Random object
36+ /// @param random Pointer to Random object to initialize
37+ /// @param set_seed_function Used set seed function
38+ /// @param get_next_uint32_function used get next uint32 function
39+ void RandomInit (Random * const random ,
40+ SetSeed set_seed_function ,
41+ GetNextUInt32 get_next_uint32_function );
42+
3143void RandomDelete (Random * * random );
3244
3345#endif /* UTILS_RANDOM_H_ */
You can’t perform that action at this time.
0 commit comments