On Mon, Jul 28, 2014 at 03:22:07PM +0200, Bert Vermeulen wrote:
>
> > static int format_match(const char *filename)
> > {
> > char buf[40];
> >
> > if (get_wav_header(filename, buf) != SR_OK)
> > return FALSE;
> >
> > if (strncmp(buf, "RIFF", 4))
> > return FALSE;
> > if (strncmp(buf + 8, "WAVE", 4))
> > return FALSE;
> > if (strncmp(buf + 12, "fmt ", 4))
> > return FALSE;
> > if (GUINT16_FROM_LE(*(uint16_t *)(buf + 20)) != 1)
> > /* Not PCM. */
> > return FALSE;
> > if (strncmp(buf + 36, "data", 4))
> > return FALSE;
> >
> > return TRUE;
> > }
>
> I don't get it, how would that not be aligned on 16 bits? It's allocated
> memory + 20 bytes.
buf is an array of type char, so there's no requirement for it to start
on a 16-bit boundary. The compiler could put buf at an odd address, and
then buf + 20 would also be at an odd address, making a 16-bit read from
buf + 20 invalid if the architecture doesn't support unaligned reads.
Martin
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel