Fix Linux compile: "free" needs stdlib.h.

Also move to .cxx file to avoid another include dependency in the header.
This commit is contained in:
ThorstenB 2012-10-04 21:11:35 +02:00
parent c188f6e3cb
commit e30ea5206f
3 changed files with 8 additions and 7 deletions

View File

@ -26,7 +26,7 @@
# include <simgear_config.h> # include <simgear_config.h>
#endif #endif
#include <stdlib.h> // rand() #include <stdlib.h> // rand(), free()
#include <cstring> #include <cstring>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
@ -232,4 +232,7 @@ SGPath SGSoundSample::file_path() const
return SGPath(_refname); return SGPath(_refname);
} }
void SGSoundSample::free_data()
{
if ( _data != NULL ) free( _data ); _data = NULL;
}

View File

@ -68,7 +68,7 @@ public:
* Constructor. * Constructor.
* @param data Pointer to a memory buffer containing this audio sample data * @param data Pointer to a memory buffer containing this audio sample data
The application may free the data by calling free_data(), otherwise it The application may free the data by calling free_data(), otherwise it
will be resident untill the class is destroyed. This pointer will be will be resident until the class is destroyed. This pointer will be
set to NULL after calling this function. set to NULL after calling this function.
* @param len Byte length of array * @param len Byte length of array
* @param freq Frequency of the provided data (bytes per second) * @param freq Frequency of the provided data (bytes per second)
@ -188,9 +188,7 @@ public:
/** /**
* Free the data associated with this audio sample * Free the data associated with this audio sample
*/ */
void free_data() { void free_data();
if ( _data != NULL ) free( _data ); _data = NULL;
}
/** /**
* Set the source id of this source * Set the source id of this source

View File

@ -203,7 +203,7 @@ public:
/** /**
* Get a free OpenAL buffer-id * Get a free OpenAL buffer-id
* The buffer-id will be asigned to the sample by calling this function. * The buffer-id will be assigned to the sample by calling this function.
* @param sample Pointer to an audio sample to assign the buffer-id to * @param sample Pointer to an audio sample to assign the buffer-id to
* @return NO_BUFFER if loading of the buffer failed. * @return NO_BUFFER if loading of the buffer failed.
*/ */