]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/morse.cxx
Minor file mode issue.
[flightgear.git] / src / Sound / morse.cxx
index 0943b8a8613e50c50f0e54d98c1c84f01fee3d96..7ae7cac98871672cd553aaca2d2b6ac83e18682e 100644 (file)
 // $Id$
 
 
-#include <memory>
-
 #include <simgear/constants.h>
 
 #include "morse.hxx"
 
+#include <cstring>
 
 static const char alphabet[26][4] = {
-    { DI, DAH, end, end },     /* A */ 
+    { DI, DAH, END, END },     /* A */ 
     { DA, DI, DI, DIT },       /* B */ 
     { DA, DI, DA, DIT },       /* C */ 
-    { DA, DI, DIT, end },      /* D */ 
-    { DIT, end, end, end },    /* E */ 
+    { DA, DI, DIT, END },      /* D */ 
+    { DIT, END, END, END },    /* E */ 
     { DI, DI, DA, DIT },       /* F */ 
-    { DA, DA, DIT, end },      /* G */ 
+    { DA, DA, DIT, END },      /* G */ 
     { DI, DI, DI, DIT },       /* H */ 
-    { DI, DIT, end, end },     /* I */ 
+    { DI, DIT, END, END },     /* I */ 
     { DI, DA, DA, DAH },       /* J */ 
-    { DA, DI, DAH, end },      /* K */ 
+    { DA, DI, DAH, END },      /* K */ 
     { DI, DA, DI, DIT },       /* L */ 
-    { DA, DAH, end, end },     /* M */ 
-    { DA, DIT, end, end },     /* N */ 
-    { DA, DA, DAH, end },      /* O */ 
+    { DA, DAH, END, END },     /* M */ 
+    { DA, DIT, END, END },     /* N */ 
+    { DA, DA, DAH, END },      /* O */ 
     { DI, DA, DA, DIT },       /* P */ 
     { DA, DA, DI, DAH },       /* Q */ 
-    { DI, DA, DIT, end },      /* R */ 
-    { DI, DI, DIT, end },      /* S */ 
-    { DAH, end, end, end },    /* T */ 
-    { DI, DI, DAH, end },      /* U */ 
+    { DI, DA, DIT, END },      /* R */ 
+    { DI, DI, DIT, END },      /* S */ 
+    { DAH, END, END, END },    /* T */ 
+    { DI, DI, DAH, END },      /* U */ 
     { DI, DI, DI, DAH },       /* V */ 
-    { DI, DA, DAH, end },      /* W */ 
+    { DI, DA, DAH, END },      /* W */ 
     { DA, DI, DI, DAH },       /* X */ 
     { DA, DI, DA, DAH },       /* Y */ 
     { DA, DA, DI, DIT }                /* Z */ 
@@ -195,7 +194,7 @@ SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
     for ( i = 0; i < (int)id.length(); ++i ) {
        if ( idptr[i] >= 'A' && idptr[i] <= 'Z' ) {
            int c = (int)(idptr[i] - 'A');
-           for ( j = 0; j < 4 || alphabet[c][j] == end; ++j ) {
+           for ( j = 0; j < 4 && alphabet[c][j] != END; ++j ) {
                if ( alphabet[c][j] == DIT ) {
                    length += DIT_SIZE;
                } else if ( alphabet[c][j] == DAH ) {
@@ -221,15 +220,15 @@ SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
     length += 2 * SPACE_SIZE;
 
     // 2. Allocate space for the message
-    std::auto_ptr<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.get();
+    unsigned char *buf_ptr = (unsigned char*)buffer;
 
     for ( i = 0; i < (int)id.length(); ++i ) {
        if ( idptr[i] >= 'A' && idptr[i] <= 'Z' ) {
            int c = (int)(idptr[i] - 'A');
-           for ( j = 0; j < 4 || alphabet[c][j] == end; ++j ) {
+           for ( j = 0; j < 4 && alphabet[c][j] != END; ++j ) {
                if ( alphabet[c][j] == DIT ) {
                    memcpy( buf_ptr, dit_ptr, DIT_SIZE );
                    buf_ptr += DIT_SIZE;
@@ -263,7 +262,7 @@ 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 );
 
     sample->set_reference_dist( 10.0 );