Adding memory alloc check, or actually the add item check wich return -1 on error