diff --git a/cpu.cpp b/cpu.cpp index 86d8caa..e2c24d5 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -57,15 +57,9 @@ std::optional cpu::check_breakpoint() int cpu::set_breakpoint(breakpoint *const bp) { - int id = 0; + breakpoints.insert({ ++bp_nr, bp }); - do { - id = rand(); - } while(breakpoints.find(id) != breakpoints.end()); - - breakpoints.insert({ id, bp }); - - return id; + return bp_nr; } bool cpu::remove_breakpoint(const int bp_id) diff --git a/cpu.h b/cpu.h index f7c4935..38b990d 100644 --- a/cpu.h +++ b/cpu.h @@ -64,6 +64,7 @@ private: std::atomic_bool any_queued_interrupts { false }; std::map breakpoints; + int bp_nr { 0 }; bus *const b { nullptr };