Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-6548

Memory management of DocInfo structs is annoying to clients

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Minor
    • 2.0
    • None
    • storage-engine
    • Security Level: Public
    • None

    Description

      In the CouchStore API, memory management of DocInfo structs is inconsistent. Sometimes the struct must be allocated and managed by the client (e.g. when calling couchstore_save_document), other times it's allocated and returned by CouchStore and must be freed using a special couchstore_free_docinfo call (e.g. couchstore_docinfo_by_id).

      It seems to happen fairly often in writing client code that you need to hang onto a DocInfo*, but sometimes that struct was allocated by CouchStore and sometimes by the app. This then requires keeping a flag alongside it that remembers who allocated it. Making mistakes can lead to crashes (Dustin has complained about this to me.)

      I propose we add a new call couchstore_alloc_docinfo that allocates a DocInfo struct the same way that CouchStore does internally. The client can then call this when it needs to allocate its own DocInfos, and not have two different kinds of freeing to worry about.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jens Jens Alfke
            jens Jens Alfke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty