The author wouldn't get paid for a returned copy either. And publishers have very wide discretion over things like giving out freebie copies — in pretty much every standard publishing contract they control what happens to the books, not the author. An author is usually given a small amount of copies of the book (in O'Reilly's case 10) — beyond that what happens to all the rest is entirely in the publisher's hands.