Simplified stats_event.c; exposed getter methods

Simplifications/changes:
(1) We remove the bufPos field and track the end of the buffer using
    only the size field.
(2) We rename put_<type>() functions to append_<type>() to signify that the
    value will be placed at the end of the buffer. We also move the
    increment of event->size to within the append_<type>() functions;
    this improves readability of the write_<type>() functions.
(3) We immediately write the timestamp and atom id to the buffer in
    order to simplify stats_event_build().
(4) We never check for null pointers; checking for null pointers
    delays errors and obfuscates the root problem.
(5) We change the the annotationId and numPairs parameters to be
    uint8_t's. This helps signify to clients that these values must fit
    in 1 byte.
(6) Clients no longer have to pass in the length of strings. Instead, we
    expect them to pass in null-terminated strings, and we will
    calculate the length outselves using strnlen.

Test: m -j libstatssocket
Change-Id: I6d192768876a23d7016173bcdaf59f8b7e92b182
Merged-In: I0173f8bc76ef25118379dce5d2481f5f7a9b7519
2 files changed