Giter Site home page Giter Site logo

Comments (7)

jblachly avatar jblachly commented on July 29, 2024

Code LGTM, probably you are seeing a double-free since I did not disable copies.
If you @disable this(this) and then attempt your test you should see a compilation failure indicating that a copy is not allowed. Can you confirm this?

from dklib.

jblachly avatar jblachly commented on July 29, 2024

If you confirm this is the problem I will either disable copies or add copy constructor since that is a relatively new feature in Dlang

from dklib.

charlesgregory avatar charlesgregory commented on July 29, 2024

Yes disabling copies provides me with a long list of compilation errors.

from dklib.

jblachly avatar jblachly commented on July 29, 2024

@charlesgregory can you please provide example code of how you are using nested hashmaps to better understand how we can work around this? I am in favor of disabling copies, but we could potentially instead do refcounting

from dklib.

charlesgregory avatar charlesgregory commented on July 29, 2024
auto kmers = khash!(string, khash!(string, int))();

 for loop {
    string kmer1;
    string kmer2;

    // if kmer1 not present create empty hashmap
    // initval is empty hashmap
    kmers.require(kmer1, khash!(string, int)()); // <- segfault when kfrees are commented out

    // if kmer2 not present make count zero
    kmers[kmer1].require(kmer2, 0);
  
    kmers[kmer1][kmer2]++;

}

This could potentially be solved by having special compile time checks for a value type that is another khash instance. Might be difficult.

from dklib.

jblachly avatar jblachly commented on July 29, 2024

Yeah you are constructing the object in the parameter position and it is copied into the function.

from dklib.

jblachly avatar jblachly commented on July 29, 2024

Changing the ctor function signature value parameter to include auto ref may fix this although ia m not sure whether should do that or write copy constructor (or both)

from dklib.

Related Issues (2)

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.