dwg_next_handle (const Dwg_Data *dwg)
{
  BITCODE_H last_hdl;
  unsigned long seed = 0;
  // check the object map for the next available handle
  last_hdl = dwg->num_object_refs ? dwg->object_ref[ dwg->num_object_refs - 1] : NULL;
  if (last_hdl)
    {
      // find the largest handle
      seed = last_hdl->absolute_ref;
      //LOG_TRACE ("compute HANDSEED %lu ", seed);
      for (unsigned i = 0; i < dwg->num_object_refs; i++)
        {
          Dwg_Object_Ref *ref = dwg->object_ref[i];
          if (ref->absolute_ref > seed)
            seed = ref->absolute_ref;
        }
      return seed + 1;
    }
  else
    {
      Dwg_Object *obj = &dwg->object[dwg->num_objects - 1];
      return obj->handle.value + 1;
    }
}
dwg_next_handle (const Dwg_Data *dwg)
{
  BITCODE_H last_hdl;
  unsigned long seed = 0;
   
  last_hdl = dwg->num_object_refs ? dwg->object_ref[ dwg->num_object_refs - 1] : NULL;
  if (last_hdl)
    {
       
      seed = last_hdl->absolute_ref;
       
      for (unsigned i = 0; i < dwg->num_object_refs; i++)
        {
          Dwg_Object_Ref *ref = dwg->object_ref[i];
          if (ref->absolute_ref > seed)
            seed = ref->absolute_ref;
        }
      return seed + 1;
    }
  else
    {
      Dwg_Object *obj = &dwg->object[dwg->num_objects - 1];
      return obj->handle.value + 1;
    }
}