Implement APIs for the counter extension

Use `size_t`.