profiling can be disabled with a define, also added a function that allocates the memory for the user. with this it's easier to exclude profiling and don't allocate a buffer when it's not needed.

this it tested on linux-32, but should be portable and working!