comparison src/midifile.c @ 49:1efee62c0f96

Possibly fix MIDI loading(?)
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 06 Aug 2013 15:39:53 +0300
parents d77dd667d9d6
children 275b6c78f03b
comparison
equal deleted inserted replaced
48:d77dd667d9d6 49:1efee62c0f96
109 109
110 static int midiStrNCmp(_MIDI_FILE *pMF, const char *str, const size_t n) 110 static int midiStrNCmp(_MIDI_FILE *pMF, const char *str, const size_t n)
111 { 111 {
112 if (pMF->curr + n < pMF->end) 112 if (pMF->curr + n < pMF->end)
113 { 113 {
114 int res = strncmp((char *) pMF->curr, str, n); 114 int res = memcmp(pMF->curr, str, n);
115 pMF->curr += n; 115 pMF->curr += n;
116 return res; 116 return res;
117 } 117 }
118 else 118 else
119 return 1; 119 return 1;
497 if ((pMF->curr = pMF->ptr = (Uint8 *) malloc(pMF->file_size)) == NULL) 497 if ((pMF->curr = pMF->ptr = (Uint8 *) malloc(pMF->file_size)) == NULL)
498 { 498 {
499 midiError(pMF, "Could not allocate %d bytes for MIDI file.\n", pMF->file_size); 499 midiError(pMF, "Could not allocate %d bytes for MIDI file.\n", pMF->file_size);
500 goto error; 500 goto error;
501 } 501 }
502
503 pMF->end = pMF->ptr + pMF->file_size;
502 504
503 fseek(fp, 0L, SEEK_SET); 505 fseek(fp, 0L, SEEK_SET);
504 if (fread(pMF->ptr, sizeof(Uint8), pMF->file_size, fp) != pMF->file_size) 506 if (fread(pMF->ptr, sizeof(Uint8), pMF->file_size, fp) != pMF->file_size)
505 { 507 {
506 midiError(pMF, "Error reading file data.\n"); 508 midiError(pMF, "Error reading file data.\n");