Aw term

From ActiveWiki
Jump to navigation Jump to search


Minimum requirements
Added in version 2.1
SDKbuild 13


void aw_term (void)

Description

Terminates use of the SDK.

Callback

None (returns immediately)

Notes

This method deallocates any resources used by instances that have been created. Instances are created using aw_create, aw_create_resolved and aw_server_admin. If a call is placed to this method from within a callback or event handler then it could leave dangling pointers in the SDK. Possibly causing a general protection fault (GPF) when it tries to access memory that has been freed.

Any installed callback or event handlers will remain and be used again if the SDK is initialized.

The aw_destroy method should be used to safely destroy instances from within callback or event handlers. This is because aw_destroy does not deallocate them at once. They merely get flagged as "destroyed" which stops the SDK from processing packets for them.

Calling aw_destroy for all instances followed by aw_wait (0) is almost the same as calling aw_term. This is because aw_wait will deallocate instances marked as "destroyed". Only difference is that it would not be necessary to call aw_init again before creating instances.

Note that aw_destroy followed by aw_wait (0) within a callback or event handler is as bad as aw_term because both would deallocate the instance.

Arguments

None

Argument attributes

None

Return values

None

Returned attributes

None

Usage

#include "Aw.h"
#include "Reason.h"

int main (int argc, char *argv[])
{
  if (aw_init (AW_BUILD) != RC_SUCCESS)
  {
    printf ("Build #%d of Aw.dll is required to run this bot.\n", AW_BUILD);
    return 1;
  }
  
  /* ... */
  
  aw_term ();
  return 0;
}

See also