Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-2119

Enable libbson users to do manual buffer management

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I request that the following functions be exposed as a public api:

      bool bson_reserve(bson_t *bson, uint32_t size);
      uint32_t bson_capacity(bson_t *bson);
      

      bson_reserve currently exists as the hidden function _bson_grow.
      bson_capacity could be implemented like his:

      uint32_t bson_capacity(bson_t *bson) {
         if (bson->flags & BSON_FLAG_INLINE) {
            return ((bson_impl_inline_t *) bson)->len;
         } else {
            return ((bson_impl_alloc_t *) bson)->len;
         }
      }
      

      These functions would be useful in cases where the developer is dynamically building a bson document – using the bson_append_*() functions – but already has a high degree of knowledge about the size of the resulting document (or just makes a guess and wants to remove the amount of calls to realloc() drastically).

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            karo Karolin Varner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: