News Score: Score the News, Sort the News, Rewrite the Headlines

Writing a simple pool allocator in C

In our simple implementation, we will declare a Chunk type with a fixed size. In a more general implementation, we would use a chunk size specified by the programmer at runtime, but that method adds a lot of casts, and I think it would make this article more confusing. First, let’s have a look at the definition of Chunk. #define CHUNK_SZ 64 typedef union Chunk Chunk; union Chunk { Chunk* next; char arr[CHUNK_SZ]; }; Notice how we are typedef’ing a union, not a struct. If you are not familiar wit...

Read more at 8dcc.github.io

© News Score  score the news, sort the news, rewrite the headlines