Giter Club home page Giter Club logo

pool's People

Contributors

jobtalle avatar pradeepgoswami90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

pool's Issues

how to understand poolFree(xx,xx) api ?

I have take a deep look at the source, but I still cannot understand, why poolFreed structure can be used to store the freed memory address ? the structure only have a *nextFree element which mean it is just an empty list, how can you store the memory pool address in the structure , I don't understand the deep meaning , please help me, thanks ?

typedef struct poolFreed{
    struct poolFreed *nextFree;
} poolFreed;

void poolFree(pool *p, void *ptr)
{
    poolFreed *pFreed = p->freed;

    p->freed = ptr;
    p->freed->nextFree = pFreed;
}

To verify this usage, but it cannot workout, sample test code as below, it would cause SIGSEGV, what's the difference between this and the sample code?

#include <stdio.h>
#include <stdlib.h>

typedef struct list{
    struct list *next;
} list;

void insert(list *l, void *ptr)
{
    list *p = l;
    l = ptr;
    l->next = p;
}
int main()
{
    list root;
    //int i = 10;
    //char c = 'a';
    //double d = 100.00;
    char *i = malloc(100);
    char *c = malloc(100);
    char *d = malloc(100);

    printf("i=%p,c=%p,d=%p\n", &i, &c, &d);

    insert(&root, i);
    insert(&root, c);
    insert(&root, d);

    list *l = &root;
    while (l)
    {
        printf("list= %p\n", l);
        l = l->next;
    }
}

About the API

Hi, thanks for sharing this repo. I read the code and just don't understand this API:

pool/pool.h

Line 25 in 05b7492

void *poolMalloc(pool *p);

void *poolMalloc(pool *p);

What I expect is something like:

void* poolMalloc(pool*p, size_t size);

which can be called, as replacement of malloc like this:

int* data = (int*)malloc(100*sizeof(int)); // before
int* data = (int*)poolMalloc(p, 100*sizeof(int)); // after

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.