Don't use malloc when not required.
Make map fixed size, and allocate memory at initialization time.