UIntPtris the wrong type to represent a count (it's basically avoid *). You wantUInt32orUInt64depending on your architecture.UIntPtris the wrong type to represent a count (it's basically avoid *). You wantUInt32orUInt64depending on your architecture.Countshould beprivate set; callers should not be able to change it directly- Why are
elemsizeandalloclengthboth signedints? Shouldn't they be unsigned? Or at least check the incomingelemsizein the constructor? - I hope that the documentation explains that the
FreeFunctionis for freeing individual elements that theStackowns if it gets destroyed nonempty. - What's supposed to happen when they
Popan empty stack? Right now you get undefined behavior. - What's supposed to happen if the
malloc()orrealloc()fails?