Recently I posted a thread for my memory leaks. I managed to fix them, but I didn't want to bring the topic again so I didn't answer.
So I said: Why shoud I believe in what other software says about my program? Lets track all the allocation and dellocations. This way I'll be sure everything is alright. But if I start... hmh it would be better if I create a whole memory pool. It would be more experience for me...
-Intro & reasons why I need the answer of the questions. Skip if you want, I just can't ask the question without giving more information than it is needed -
Ok I read some memory pool tutorials... I didn't understand anything so I created a fresh C++ project and started coding it. Amazing but it is behaving really well even if I overload the global new operator 0_0. I made all tests I could imagine.. The alloc time is really good is most cases, however I could make a situation which requires large amout of time. This time I started editing it to get it working better.
All chunks from my pool need a header which saves their status. I already made an algorithm which will do the job but it requires 2 bytes header for each chunk(now I'm using one byte, and each bit has different meaning for my chunk). My new functions working with bits are using unsigned shorts as arguments/parameters. So..
How do I take two bytes(chars) and convert them to a single short? (everything is unsigned)
char a[2]; a[0] = 1; a[1] = 2;
short b = a;(!?!? how shoud I cast it)
cout << b; It shoud print 258
EDIT: Didn't notice I have posted it in game programming. Sorry!
char a[2]; a[0] = 1; a[1] = 2;
short b = a;(!?!? how shoud I cast it)
cout << b; It shoud print 258