Ejemplo n.º 1
0
void *
tiz_os_get_type (const tiz_os_t * ap_os, const char * a_type_name)
{
  void * res = NULL;
  assert (ap_os);
  assert (ap_os->p_map);
  assert (a_type_name);
  res = tiz_map_find (ap_os->p_map, (OMX_PTR) a_type_name);
  TIZ_TRACE (ap_os->p_hdl, "Get type [%s]->[%p] - total types [%d]",
             a_type_name, res, tiz_map_size (ap_os->p_map));
  if (!res)
    {
      if (OMX_ErrorNone
          == register_additional_type ((tiz_os_t *) ap_os, a_type_name))
        {
          print_types (ap_os);
          res = tiz_map_find (ap_os->p_map, (OMX_PTR) a_type_name);
        }
    }
  assert (res);
  return res;
}
Ejemplo n.º 2
0
END_TEST

START_TEST (test_map_insert_find_erase_size_empty_at_for_each)
{
  OMX_U32 i;
  OMX_ERRORTYPE error = OMX_ErrorNone;
  int *p_item = NULL;
  tiz_map_t *p_map = NULL;;
  OMX_U32 index = 0;

  error = tiz_map_init (&p_map, check_map_cmp_f, check_map_free_f, NULL);
  fail_if (error != OMX_ErrorNone);

  fail_if (false == tiz_map_empty (p_map));

  for (i = 0; i < 10; i++)
    {
      p_item = (int *) tiz_mem_alloc (sizeof (int));
      fail_if (p_item == NULL);
      *p_item = i;
      error = tiz_map_insert (p_map, p_item, p_item, &index);
      fail_if (error != OMX_ErrorNone);
      fail_if (index != i);
      fail_if (tiz_map_size (p_map) != i+1);
    }

  fail_if (10 != tiz_map_size (p_map));
  fail_if (true == tiz_map_empty (p_map));

  i = 5;
  fail_if (5 != *(p_item = tiz_map_find (p_map, &i)));

  fail_if (5 != *(p_item = tiz_map_value_at (p_map, i)));

  fail_if (OMX_ErrorNone != tiz_map_for_each (p_map,
                                              check_map_for_each_f,
                                              NULL));


  for (i = 0; i < 10; i++)
    {
      int d = i;
      tiz_map_erase (p_map, &d);
      fail_if (tiz_map_size (p_map) != 9-i);
    }

  tiz_map_destroy (p_map);

}
Ejemplo n.º 3
0
OMX_ERRORTYPE
tiz_map_insert (tiz_map_t * ap_map, OMX_PTR ap_key,
                OMX_PTR ap_value, OMX_U32 * ap_index)
{
  tiz_map_item_t *p_item = NULL;

  assert (NULL != ap_map);
  assert (NULL != ap_key);
  assert (NULL != ap_map->p_tree);
  assert (NULL != ap_index);

  if (NULL != tiz_map_find (ap_map, ap_key))
    {
      return OMX_ErrorBadParameter;
    }

  if (NULL == (p_item = (tiz_map_item_t *)
               map_calloc (ap_map->p_soa, sizeof (tiz_map_item_t))))
    {
      return OMX_ErrorInsufficientResources;
    }

  p_item->p_key = ap_key;
  p_item->p_value = ap_value;
  p_item->p_map = ap_map;

  if (-1 == avl_insert_by_key (ap_map->p_tree, p_item, ap_index))
    {
      map_free (ap_map->p_soa, p_item);
      p_item = NULL;
      return OMX_ErrorInsufficientResources;
    }

  ap_map->size++;

  TIZ_LOG (TIZ_TRACE, "Inserted in map. size [%d]", ap_map->size);

  return OMX_ErrorNone;
}