On 2017/01/06 21:03, Jörg Raftopoulos <jo...@raftopoulos.net> wrote:
> Now without fstream as requested.

There is still no patch description (= commit message).

Did you ensure that your code compiles with the old libsidplay?  It
looks suspicious.

> +               buffer = new char[romSize];

Your code is not exception-safe, and can leak memory.  Better manage
this pointer with std::unique_ptr.

> +               fread(buffer, romSize, 1, rom);

Checks missing.  What if the file is smaller?  What if the file is
larger?  What if a read error occurs?

Also I suggest to use MPD's class FileReader.  Your code uses buffered
I/O, but that buffering is of no use; it only adds unnecessary
overhead.

One more problem with stdio: it is not thread-safe.  As in: leaks file
descriptors, because it doesn't set O_CLOEXEC.  There is a GNU
extension to set O_CLOEXEC, but your code doesn't use it, and anyway
it isn't portable.

> +                FormatError(sidplay_domain,
> +                            "unable to load rom dump %s", path);

Instead of logging an error message, the error condition should be
returned to the caller, so the caller can decide what to do with it.
For example by throwing an exception.
_______________________________________________
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel

Reply via email to