More expressive variable names in load_phdr

This commit is contained in:
Marcus Weseloh 2018-04-04 11:03:47 +02:00
parent 9c31e96c60
commit 74e2a4b933

View file

@ -796,8 +796,8 @@ static int process_pdta(int size, SFData *sf, void *fd, const fluid_file_callbac
static int load_phdr(int size, SFData *sf, void *fd, const fluid_file_callbacks_t *fcbs) static int load_phdr(int size, SFData *sf, void *fd, const fluid_file_callbacks_t *fcbs)
{ {
int i, i2; int i, i2;
SFPreset *p, *pr = NULL; /* ptr to current & previous preset */ SFPreset *preset, *prev_preset = NULL;
unsigned short zndx, pzndx = 0; unsigned short pbag_idx, prev_pbag_idx = 0;
if (size % SFPHDRSIZE || size == 0) if (size % SFPHDRSIZE || size == 0)
{ {
@ -815,49 +815,49 @@ static int load_phdr(int size, SFData *sf, void *fd, const fluid_file_callbacks_
for (; i > 0; i--) for (; i > 0; i--)
{ /* load all preset headers */ { /* load all preset headers */
p = FLUID_NEW(SFPreset); preset = FLUID_NEW(SFPreset);
sf->preset = fluid_list_append(sf->preset, p); sf->preset = fluid_list_append(sf->preset, preset);
p->zone = NULL; /* In case of failure, fluid_sf2_close can cleanup */ preset->zone = NULL; /* In case of failure, fluid_sf2_close can cleanup */
READSTR(&p->name, fd, fcbs); /* possible read failure ^ */ READSTR(&preset->name, fd, fcbs); /* possible read failure ^ */
READW(p->prenum, fd, fcbs); READW(preset->prenum, fd, fcbs);
READW(p->bank, fd, fcbs); READW(preset->bank, fd, fcbs);
READW(zndx, fd, fcbs); READW(pbag_idx, fd, fcbs);
READD(p->libr, fd, fcbs); READD(preset->libr, fd, fcbs);
READD(p->genre, fd, fcbs); READD(preset->genre, fd, fcbs);
READD(p->morph, fd, fcbs); READD(preset->morph, fd, fcbs);
if (pr) if (prev_preset)
{ /* not first preset? */ { /* not first preset? */
if (zndx < pzndx) if (pbag_idx < prev_pbag_idx)
{ {
FLUID_LOG(FLUID_ERR, _("Preset header indices not monotonic")); FLUID_LOG(FLUID_ERR, _("Preset header indices not monotonic"));
return FALSE; return FALSE;
} }
i2 = zndx - pzndx; i2 = pbag_idx - prev_pbag_idx;
while (i2--) while (i2--)
{ {
pr->zone = fluid_list_prepend(pr->zone, NULL); prev_preset->zone = fluid_list_prepend(prev_preset->zone, NULL);
} }
} }
else if (zndx > 0) /* 1st preset, warn if ofs >0 */ else if (pbag_idx > 0) /* 1st preset, warn if ofs >0 */
FLUID_LOG(FLUID_WARN, _("%d preset zones not referenced, discarding"), zndx); FLUID_LOG(FLUID_WARN, _("%d preset zones not referenced, discarding"), pbag_idx);
pr = p; /* update preset ptr */ prev_preset = preset; /* update preset ptr */
pzndx = zndx; prev_pbag_idx = pbag_idx;
} }
FSKIP(24, fd, fcbs); FSKIP(24, fd, fcbs);
READW(zndx, fd, fcbs); /* Read terminal generator index */ READW(pbag_idx, fd, fcbs); /* Read terminal generator index */
FSKIP(12, fd, fcbs); FSKIP(12, fd, fcbs);
if (zndx < pzndx) if (pbag_idx < prev_pbag_idx)
{ {
FLUID_LOG(FLUID_ERR, _("Preset header indices not monotonic")); FLUID_LOG(FLUID_ERR, _("Preset header indices not monotonic"));
return FALSE; return FALSE;
} }
i2 = zndx - pzndx; i2 = pbag_idx - prev_pbag_idx;
while (i2--) while (i2--)
{ {
pr->zone = fluid_list_prepend(pr->zone, NULL); prev_preset->zone = fluid_list_prepend(prev_preset->zone, NULL);
} }
return TRUE; return TRUE;