changed malloc() and free() to kernel equivalents