File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1+ module CRC
2+ end
Original file line number Diff line number Diff line change @@ -8,15 +8,20 @@ static void
88c_crc_crc32 (mrbc_vm * vm , mrbc_value v [], int argc )
99{
1010 mrbc_value string = GET_ARG (1 );
11- mrbc_int_t crc = GET_INT_ARG (2 );
11+ mrbc_int_t crc ;
12+ if (argc < 2 ) {
13+ crc = 0 ;
14+ } else {
15+ crc = GET_INT_ARG (2 );
16+ }
1217 if (string .tt == MRBC_TT_NIL ) {
1318 SET_INT_RETURN (0 );
1419 return ;
1520 } else if (string .tt != MRBC_TT_STRING ) {
1621 mrbc_raise (vm , MRBC_CLASS (TypeError ), "string expected" );
1722 return ;
1823 }
19- uint32_t crc_value = generate_crc32 ((uint8_t * )string .string -> data , string .string -> size , crc );
24+ uint32_t crc_value = generate_crc32 ((uint8_t * )string .string -> data , ( size_t ) string .string -> size , ( uint32_t ) crc );
2025 SET_INT_RETURN (crc_value );
2126}
2227
You can’t perform that action at this time.
0 commit comments