mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-27 03:21:15 +00:00
Replace debounce malloc+loop with calloc
* Replace malloc() with calloc() * Eliminate zero-initialization loops * Minor code spacing edit
This commit is contained in:
parent
a954b568ea
commit
6e43a23312
@ -64,13 +64,7 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
|
||||
|
||||
// we use num_rows rather than MATRIX_ROWS to support split keyboards
|
||||
void debounce_init(uint8_t num_rows) {
|
||||
debounce_counters = malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t));
|
||||
int i = 0;
|
||||
for (uint8_t r = 0; r < num_rows; r++) {
|
||||
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
|
||||
debounce_counters[i++].time = DEBOUNCE_ELAPSED;
|
||||
}
|
||||
}
|
||||
debounce_counters = calloc(num_rows * MATRIX_COLS, sizeof(debounce_counter_t));
|
||||
}
|
||||
|
||||
void debounce_free(void) {
|
||||
|
@ -56,13 +56,7 @@ static void start_debounce_counters(matrix_row_t raw[], matrix_row_t cooked[], u
|
||||
|
||||
// we use num_rows rather than MATRIX_ROWS to support split keyboards
|
||||
void debounce_init(uint8_t num_rows) {
|
||||
debounce_counters = (debounce_counter_t *)malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t));
|
||||
int i = 0;
|
||||
for (uint8_t r = 0; r < num_rows; r++) {
|
||||
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
|
||||
debounce_counters[i++] = DEBOUNCE_ELAPSED;
|
||||
}
|
||||
}
|
||||
debounce_counters = calloc(num_rows * MATRIX_COLS, sizeof(debounce_counter_t));
|
||||
}
|
||||
|
||||
void debounce_free(void) {
|
||||
|
@ -34,7 +34,6 @@ static matrix_row_t* last_raw;
|
||||
void debounce_init(uint8_t num_rows) {
|
||||
countdowns = (uint8_t*)calloc(num_rows, sizeof(uint8_t));
|
||||
last_raw = (matrix_row_t*)calloc(num_rows, sizeof(matrix_row_t));
|
||||
|
||||
last_time = timer_read();
|
||||
}
|
||||
|
||||
|
@ -57,13 +57,7 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
|
||||
|
||||
// we use num_rows rather than MATRIX_ROWS to support split keyboards
|
||||
void debounce_init(uint8_t num_rows) {
|
||||
debounce_counters = (debounce_counter_t *)malloc(num_rows * MATRIX_COLS * sizeof(debounce_counter_t));
|
||||
int i = 0;
|
||||
for (uint8_t r = 0; r < num_rows; r++) {
|
||||
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
|
||||
debounce_counters[i++] = DEBOUNCE_ELAPSED;
|
||||
}
|
||||
}
|
||||
debounce_counters = calloc(num_rows * MATRIX_COLS, sizeof(debounce_counter_t));
|
||||
}
|
||||
|
||||
void debounce_free(void) {
|
||||
|
@ -56,10 +56,7 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
|
||||
|
||||
// we use num_rows rather than MATRIX_ROWS to support split keyboards
|
||||
void debounce_init(uint8_t num_rows) {
|
||||
debounce_counters = (debounce_counter_t *)malloc(num_rows * sizeof(debounce_counter_t));
|
||||
for (uint8_t r = 0; r < num_rows; r++) {
|
||||
debounce_counters[r] = DEBOUNCE_ELAPSED;
|
||||
}
|
||||
debounce_counters = calloc(num_rows, sizeof(debounce_counter_t));
|
||||
}
|
||||
|
||||
void debounce_free(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user