Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ATT_Cellular_IOT_Button Avnet_ATT_Cellular_Pubnub Hiking_Pal Avnet_ATT_Cellular_IOT ... more
Fork of MODSERIAL by
Diff: INIT.cpp
- Revision:
- 8:775f860e94d3
- Parent:
- 4:28de979b77cf
- Child:
- 9:b3cdae80e7a9
--- a/INIT.cpp Mon Nov 22 09:19:50 2010 +0000 +++ b/INIT.cpp Mon Nov 22 09:58:34 2010 +0000 @@ -40,7 +40,7 @@ if (_base != NULL) { buffer_size[RxIrq] = rxSize; - buffer[RxIrq] = (char *)malloc(buffer_size[RxIrq]); + buffer[RxIrq] = rxSize > 0 ? (char *)malloc(buffer_size[RxIrq]) : (char *)NULL; buffer_in[RxIrq] = 0; buffer_out[RxIrq] = 0; buffer_count[RxIrq] = 0; @@ -48,7 +48,7 @@ Serial::attach(this, &MODSERIAL::isr_rx, Serial::RxIrq); buffer_size[TxIrq] = txSize; - buffer[TxIrq] = (char *)malloc(buffer_size[TxIrq]); + buffer[TxIrq] = txSize > 0 ? (char *)malloc(buffer_size[TxIrq]) : (char *)NULL; buffer_in[TxIrq] = 0; buffer_out[TxIrq] = 0; buffer_count[TxIrq] = 0; @@ -59,14 +59,6 @@ error("MODSERIAL must have a defined UART to function."); } - if (!txBufferSane()) { - error("Failed to allocate memory for TX buffer"); - } - - if (!rxBufferSane()) { - error("Failed to allocate memory for RX buffer"); - } - _FCR = MODSERIAL_FIFO_ENABLE | MODSERIAL_FIFO_RX_RESET | MODSERIAL_FIFO_TX_RESET; enableIrq();