Checking for size greater than 0 before allocating memory