fixed possible memory leak

Calling "hwc_prepare" allocates memory for hwc_layer_rd.
The allocated memory isn't freed, leaving a memory leak.

Since the function seems to be called quite often.
To reduce the calls of malloc and free, I moved the allocation handling into the open and closing functions of the device.