static scpi_bool_t SCPI_ErrorAddInternal(scpi_t * context, int16_t err, char * info, size_t info_len) { scpi_error_t error_value; char * info_ptr = info ? SCPIDEFINE_strndup(&context->error_info_heap, info, info_len) : NULL; SCPI_ERROR_SETVAL(&error_value, err, info_ptr); if (!fifo_add(&context->error_queue, &error_value)) { SCPIDEFINE_free(&context->error_info_heap, error_value.device_dependent_info, true); fifo_remove_last(&context->error_queue, &error_value); SCPIDEFINE_free(&context->error_info_heap, error_value.device_dependent_info, true); SCPI_ERROR_SETVAL(&error_value, SCPI_ERROR_QUEUE_OVERFLOW, NULL); fifo_add(&context->error_queue, &error_value); return FALSE; } return TRUE; }
static void SCPI_ErrorAddInternal(scpi_t * context, int16_t err) { if (!fifo_add(&context->error_queue, err)) { fifo_remove_last(&context->error_queue, NULL); fifo_add(&context->error_queue, SCPI_ERROR_QUEUE_OVERFLOW); } }