]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/morse.cxx
Change of thoughts since it makes life easier:
[flightgear.git] / src / Sound / morse.cxx
index 855d7b2651b052c0c23ef7b7915c954f3641d02f..942b637a5a2ae46ecf1687994fdd2e82983ce386 100644 (file)
@@ -16,7 +16,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
@@ -167,6 +167,7 @@ bool FGMorse::cust_init(const int freq ) {
 
 // make a SGSoundSample morse code transmission for the specified string
 SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
+
     char *idptr = (char *)id.c_str();
 
     int length = 0;
@@ -218,10 +219,10 @@ SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
     length += 2 * SPACE_SIZE;
 
     // 2. Allocate space for the message
-    unsigned char *buffer = new unsigned char[length];
+    const unsigned char* buffer = (const unsigned char *)malloc(length);
 
     // 3. Assemble the message;
-    unsigned char *buf_ptr = buffer;
+    unsigned char *buf_ptr = (unsigned char*)buffer;
 
     for ( i = 0; i < (int)id.length(); ++i ) {
        if ( idptr[i] >= 'A' && idptr[i] <= 'Z' ) {
@@ -260,12 +261,9 @@ SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
     buf_ptr += SPACE_SIZE;
 
     // 4. create the simple sound and return
-    SGSoundSample *sample = new SGSoundSample( buffer, length,
+    SGSoundSample *sample = new SGSoundSample( &buffer, length,
                                                BYTES_PER_SECOND );
 
-    // clean up the buffer
-    delete [] buffer;
-
     sample->set_reference_dist( 10.0 );
     sample->set_max_dist( 20.0 );