When we use malloc() to allocate memory, should we give the size which is in power of two? Or we just give the exact size that we need?
Like
You should use realloc() instead of malloc() when reallocating. http://www.cplusplus.com/reference/clibrary/cstdlib/realloc/
Always use a power of two? It depends on what your program is doing. If you need to reprocess your whole data structure when it grows to a power of two, yeah it makes sense. Otherwise, just allocate what you need and don't hog memory.