- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/mruby-1.3.0
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-random/src/random.c
r321 r331 5 5 */ 6 6 7 #include "mruby.h"8 #include "mruby/variable.h"9 #include "mruby/class.h"10 #include "mruby/data.h"11 #include "mruby/array.h"7 #include <mruby.h> 8 #include <mruby/variable.h> 9 #include <mruby/class.h> 10 #include <mruby/data.h> 11 #include <mruby/array.h> 12 12 #include "mt19937ar.h" 13 13 … … 80 80 81 81 if (!mrb_nil_p(arg)) { 82 if (!mrb_fixnum_p(arg)) { 82 arg = mrb_check_convert_type(mrb, arg, MRB_TT_FIXNUM, "Fixnum", "to_int"); 83 if (mrb_nil_p(arg)) { 83 84 mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid argument type"); 84 85 } 85 arg = mrb_check_convert_type(mrb, arg, MRB_TT_FIXNUM, "Fixnum", "to_int");86 86 if (mrb_fixnum(arg) < 0) { 87 87 arg = mrb_fixnum_value(0 - mrb_fixnum(arg)); … … 125 125 mt_state *t; 126 126 127 seed = get_opt(mrb); 128 127 129 /* avoid memory leaks */ 128 130 t = (mt_state*)DATA_PTR(self); … … 135 137 t->mti = N + 1; 136 138 137 seed = get_opt(mrb);138 139 seed = mrb_random_mt_srand(mrb, t, seed); 139 140 if (mrb_nil_p(seed)) { … … 267 268 mrb_bool given; 268 269 mt_state *random = NULL; 269 mrb_int len = RARRAY_LEN(ary);270 mrb_int len; 270 271 271 272 mrb_get_args(mrb, "|i?d", &n, &given, &random, &mt_state_type); … … 275 276 mrb_random_rand_seed(mrb, random); 276 277 mt_rand(random); 278 len = RARRAY_LEN(ary); 277 279 if (!given) { /* pick one element */ 278 280 switch (len) {
Note:
See TracChangeset
for help on using the changeset viewer.