From 46a617a1b68b8b21eda9e590915dd813ea44e7cb Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Thu, 22 Feb 2018 22:32:14 +0100 Subject: Add const to MIDI pkt pointer arguments --- src/main.c | 2 +- src/midi.c | 4 +--- src/midi.h | 6 ++---- src/rs232.c | 3 --- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index c6a2a96..c01cb90 100644 --- a/src/main.c +++ b/src/main.c @@ -78,7 +78,7 @@ #include #include -int eusart_write_midi(midi_message_t *pkt) +int eusart_write_midi(const midi_message_t *pkt) { size_t length; uint8_t *data; diff --git a/src/midi.c b/src/midi.c index e82c921..b81cf2d 100644 --- a/src/midi.c +++ b/src/midi.c @@ -14,17 +14,15 @@ midi_message_t *midi_alloc_message(size_t data_size) void midi_free_message(midi_message_t *pkt) { -#ifndef MIDI_UNSAFE if (pkt == NULL) { return; } -#endif free(pkt); pkt = NULL; } -size_t midi_message_size(midi_message_t *pkt) +size_t midi_message_size(const midi_message_t *pkt) { if (pkt == NULL) { return 0; diff --git a/src/midi.h b/src/midi.h index cab35e3..fb85833 100644 --- a/src/midi.h +++ b/src/midi.h @@ -59,14 +59,13 @@ typedef struct { // allocation / dellocation extern midi_message_t *midi_alloc_message(size_t data_size); -extern void midi_free_message(midi_message_t *pkt); -extern size_t midi_message_size(midi_message_t *pkt); +extern void midi_free_message(const midi_message_t *pkt); +extern size_t midi_message_size(const midi_message_t *pkt); #endif // helper functions - extern int midi_set_status(midi_message_t *pkt, midi_status_t status); extern int midi_set_channel(midi_message_t *pkt, unsigned channel); @@ -77,6 +76,5 @@ extern int midi_note_off(midi_message_t *pkt, unsigned channel, midi_note_t note // optimization // extern int midi_thin_data(void *buffer, midi_message_t pkt[]); - #endif /* MIDI_H */ diff --git a/src/rs232.c b/src/rs232.c index 05d8b22..e87e49b 100644 --- a/src/rs232.c +++ b/src/rs232.c @@ -3,7 +3,6 @@ void eusart_init(void) { - // set Async and 8 bits frame TXSTAbits.SYNC = 0; TXSTAbits.TX9 = 0; @@ -23,14 +22,12 @@ void eusart_init(void) void putch(char c) { - while (!TXIF); TXREG = c; } char getch(void) { - while (!RCIF); return RCREG; } -- cgit v1.2.1