Commit bbd5d088 authored by Chris's avatar Chris
Browse files

replaced malloc() for next_roll with array

parent e4995be5
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ int main() {
	 game_context ctx;
	// initialize random device for game state
	ctx.random_device_fd = get_urandom();
	unsigned int *next_roll = malloc(sizeof(unsigned int) * NUM_DICE);
	int next_roll[NUM_DICE];

	printf("yaht.c\n");

@@ -56,17 +56,13 @@ int main() {
	set_die_held(&ctx, 0, 1);
	set_die_held(&ctx, 1, 1);
	set_die_held(&ctx, 4, 1);
	// set_die_held(&ctx, 5, 1);
	// set_die_held(&ctx, 5, 1); // tests edge case


	// second roll
	roll_multiple_dice(&ctx, next_roll, 1);
	print_multiple_dice(next_roll, NUM_DICE, 0);

	// free the next_roll var (mallon)
	if (next_roll) {
		free(next_roll);
	}
	fclose(ctx.random_device_fd);
	return 0;
}
−120 B (16.6 KiB)

File changed.

No diff preview for this file type.