]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/morse.cxx
Merge branch 'csaba/nan'
[flightgear.git] / src / Sound / morse.cxx
index a562732888c8c99044bcc021a7b7d408c416c4e0..df6c969face529f7572d3e55f9f15c59af5b3f7a 100644 (file)
@@ -193,7 +193,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 ) {
@@ -219,15 +219,15 @@ 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' ) {
            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;
@@ -261,7 +261,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 );