Github user alanconway commented on the pull request:

    https://github.com/apache/qpid-proton/pull/11#issuecomment-78339832
  
    On Wed, 2015-03-11 at 08:00 -0700, Andrew Stitcher wrote:
    > Thinking about it a bit more, I think I particularly object to the new
    > public API.
    > What you really want at an API level here is simply a function to tell
    > you how many bytes you need to allocate, not a strange combined
    > encode, but if you can't tell how many bytes I would need.
    
    A simpler pn_data_encoded_size() API would be easy to do but potentially
    requires scanning the data structure twice to encode...
    
    > 
    > FWIW, I think that there are some simple strategies that can get you
    > the needed size out of a pn_data_t with a little extra being held in
    > that structure, withotu having to do the full encode.
    
    I'd love to hear some details. Are you suggesting we accumulate the
    encoded size every time you modify the data?
    
    The motivation for all this is to avoid the "guess and double"
    allocation dance that the bindings currently do, e.g. in python:
    
        size = 1024
        while True:
          cd, enc = pn_data_encode(self._data, size)
          if cd == PN_OVERFLOW:
            size *= 2
    
    
    
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to