|
|
|
|
Purpose |
Free memory allocated by the Aspen library. |
|
|
|
|
Syntax |
#include <aspen.h> ... void AspenFreeMemory(notice); |
|
|
|
|
Parameters |
notice A pointer to a void pointer that receives the address of a dynamically allocated Aspen API event structure appropriate for an AspenEvent() *event_code. |
|
|
|
|
Remarks |
Some Aspen services allocate memory within the API and return pointers to this memory to the client application. This memory must be freed using AspenFreeMemory().
Note: free() memory may not be used because the memory was allocated by an Aspen memory allocation function. A memory leak will occur if AspenFreeMemory() is not used.
Data items that are allocated by the API are marked with the recycle symbol (see below) throughout this documentation.
|
|
|
|
|
Return Value |
None. |
|
|
|
|
See Also |
|
|
|
|
|
Example |
void CSuperQuoteDlg::DoASPEN_EventHandling() { ASPEN_INSTRUMENT_UPDATE_NOTICE *instrumentUpdate; ASPEN_CLOSURE_NOTICE *closureNotice; ASPEN_SESSION_FAILURE_NOTICE *failureNotice; ASPEN_DEFINE_SERVER_NOTICE *defineServer; ASPEN_ALERT_NOTICE *alertNotice; ASPEN_SYMBOL_CHANGE_NOTICE *symbolChange; ASPEN_HISTORICAL_UPDATE_NOTICE *historicalUpdate; ASPEN_TIME_SET_NOTICE *timeSet; ASPEN_TRANSPORT_AVAILABLE_NOTICE *transAvailable; ASPEN_TRANSPORT_UNAVAILABLE_NOTICE *transUnavailable; ASPEN_UNDEFINE_SERVER_NOTICE *undefServer; CString strText; int retval,event; void *notice; CSuperQuoteDlg dlg;
do{ WaitForSingleObject(GLOBAL_eventThreadHandle,100); retval = AspenEvent(&event, ¬ice); if (retval == ASPEN_OK) { CWnd *Super = FindWindow(NULL,"SuperQuoter'"); switch(event) { case ASPEN_AlertNotice: alertNotice = (ASPEN_ALERT_NOTICE *)notice; strText.Format("**ALERT** : %s",alertNotice->text); m_HistoryEdit.AppendString(strText); break; case ASPEN_ClosureNotice: closureNotice = (ASPEN_CLOSURE_NOTICE *)notice; strText.Format("**ClosureNotice** %s",closureNotice->text); m_HistoryEdit.AppendString(strText); TerminateThread(GLOBAL_eventThreadHandle, GLOBAL_eventThreadID); if (GLOBAL_eventSemaphore) CloseHandle(GLOBAL_eventSemaphore); break; case ASPEN_InstrumentUpdateNotice: instrumentUpdate = (ASPEN_INSTRUMENT_UPDATE_NOTICE *)notice; a_inst = instrumentUpdate->instrument; if (!Super) { strText.Format("Symbol: %s Last Price: %ld", instrumentUpdate->instrument.symbol, instrumentUpdate->instrument.last); m_HistoryEdit.AppendString(strText); } else DoASPEN_SuperQuote(); break; case ASPEN_HistoricalUpdateNotice: historicalUpdate = (ASPEN_HISTORICAL_UPDATE_NOTICE *)notice; strText.Format("**HistoricalUpdate** INUM: %d,DB_ID: %hd, StartTime: %ld, EndTime: %ld", historicalUpdate->inum, historicalUpdate->db_id, historicalUpdate->start_time, historicalUpdate->end_time); m_HistoryEdit.AppendString(strText); break; case ASPEN_SymbolChangeNotice: symbolChange = (ASPEN_SYMBOL_CHANGE_NOTICE *)notice; strText.Format("Symbol: %s\tOld INUM: %ld\tNew INUM: %ld", symbolChange->symbol, symbolChange->old_inum, symbolChange->new_inum); m_HistoryEdit.AppendString(strText); break; case ASPEN_TimeSetNotice: timeSet = (ASPEN_TIME_SET_NOTICE *)notice; strText.Format("**TimeSetNotice** Minutes: %ld, Seconds: %hd", timeSet->minutes, timeSet->seconds); m_HistoryEdit.AppendString(strText); break; case ASPEN_TransportAvailableNotice: transAvailable = (ASPEN_TRANSPORT_AVAILABLE_NOTICE *)notice; strText.Format("**TransportAvailable** Family: %d, Protocol: %s, Provider: %s", transAvailable->family, transAvailable->protocol, transAvailable->provider); m_HistoryEdit.AppendString(strText); break; case ASPEN_TransportUnavailableNotice: transUnavailable = (ASPEN_TRANSPORT_UNAVAILABLE_NOTICE *)notice; strText.Format("**TransportUnavailable** Family: %d, Protocol: %s, Provider: %s\nError: %s", transUnavailable->family, transUnavailable->protocol, transUnavailable->provider, transUnavailable->errorText); m_HistoryEdit.AppendString(strText); break; case ASPEN_DefineServerNotice: char buffer[12]; defineServer = (ASPEN_DEFINE_SERVER_NOTICE *)notice; sprintf(buffer,"%c%c%c%c%c%c%c%c%c%c%c", defineServer->server_name[8],defineServer->server_name[9], defineServer->server_name[10],defineServer->server_name[11], defineServer->server_name[12],defineServer->server_name[13], defineServer->server_name[14],defineServer->server_name[15], defineServer->server_name[16],defineServer->server_name[17], defineServer->server_name[18],defineServer->server_name[19]); strText.Format("%s (%d.%d.%d.%d) AVAILABLE",buffer, defineServer->address.address[0], defineServer->address.address[1], defineServer->address.address[2], defineServer->address.address[3]); m_HistoryEdit.AppendString(strText); break; case ASPEN_SessionFailureNotice: failureNotice = (ASPEN_SESSION_FAILURE_NOTICE *)notice; strText.Format("**SessionFailureNotice** %s", failureNotice->errorText); m_HistoryEdit.AppendString(strText); TerminateThread(GLOBAL_eventThreadHandle, GLOBAL_eventThreadID); if (GLOBAL_eventSemaphore) CloseHandle(GLOBAL_eventSemaphore); break; case ASPEN_UndefineServerNotice: undefServer = (ASPEN_UNDEFINE_SERVER_NOTICE *)notice; strText.Format("**UndefineServerNotice** Addr: %ld, ServerName: %s", undefServer->address, undefServer->server_name); m_HistoryEdit.AppendString(strText); break; } AspenFreeMemory(notice); } }while(retval == ASPEN_OK); } |
©2006 Aspen Research Group, Ltd. All rights reserved. Terms of Use.