C implementation for queue