Giter VIP home page Giter VIP logo

Comments (3)

berendsliedrecht avatar berendsliedrecht commented on September 21, 2024

Yeah that does not seem to be too good. I think we have three solutions but they all have some disadvantages

  1. Expose string_free publicly and allow the consumer to deal with it.
  • Downside is that this is quite the uncommon pattern in JS and likely they will still forget some allocations.
  1. Within the wrapper copy the value and immediately call it (it might even already be copied ffi-napi and c++ side).
  • Would still require all manual frees but at least we control it and not the consumer.
  1. Wait for Typescript 5.2 to be stable as it introduces the using keyword which would finally allow a cleanup function to be ran when it goes out-of-scope.

IMO it is okay to wait for typeScript 5.2 and leave this as-is for now.

from anoncreds-rs.

genaris avatar genaris commented on September 21, 2024

3. Wait for Typescript 5.2 to be stable as it introduces the using keyword which would finally allow a cleanup function to be ran when it goes out-of-scope.

Well, if that iteration plan is accurate, it will be out in 4 days from now! So definitely it's worth waiting a bit and doing not only this but also for object handle clear() methods.

If not, I'd go for option 2.

from anoncreds-rs.

andrewwhitehead avatar andrewwhitehead commented on September 21, 2024

I think the wrapper copies these FFI string buffers to Strings anyway, so it should be possible to free the reference before returning. I noticed later that this would apply to anoncreds_buffer_free as well, for binary buffers.

from anoncreds-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.