GithubHelp home page GithubHelp logo

dailymotion / chash Goto Github PK

View Code? Open in Web Editor NEW
22.0 22.0 7.0 61 KB

Very fast consistent hashing library

License: MIT License

Shell 1.99% C 69.82% PHP 6.89% Python 16.66% Makefile 2.01% CMake 0.45% Hack 2.18%

chash's People

Contributors

noony avatar pyke369 avatar sebest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chash's Issues

issues experimented running valgrind

Hi,
I am running this very simple test program (as part of a complete suite) under valgrind.

/* System headers */

include <stdio.h>

include <stdlib.h>

include <stdbool.h>

include <assert.h>

/* public header */

include "chash.h"

/* Basic allocate and free */
static void alloc_free (void)
{
CHASH_CONTEXT ht;
int ret = chash_initialize (& ht, true);
assert (ret == CHASH_ERROR_DONE);
ret = chash_terminate (& ht, true);
assert (ret == CHASH_ERROR_DONE);
}

int main (int argc, char * argv [])
{
alloc_free ();
return 0;
}

valgrind output is:
==24137== Conditional jump or move depends on uninitialised value(s)
==24137== at 0x4010AD: chash_initialize (chash.c:139)
==24137== by 0x400BA1: alloc_free (basic.c:16)
==24137== by 0x400C35: main (basic.c:27)

minor problem but annoying because it forces initialization at user level.

/rocco

fixed memory leak in chash.c

the field name is set when a target is added in chash_add_target() at line 219 in chash.c with

 if (! (context->targets[context->targets_count].name = strdup(target)))

and its is also freed in the chash_clear_targets() at line 274 with

free(context->targets[index].name);

but in the event the function chash_remove_target() is called the memory allocated with strdup() is not freed.

so the sequence create - add - destroy works well but the sequence
create - add - remove - destroy has a memory leak.

Hope it helps.
ciao
/rocco

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.