quick and dirty unmanaged extension to calculate lengths of linked lists