Пример #1
0
static void
file_delete (struct VdlFile *file, bool mapping)
{
  vdl_context_remove_file (file->context, file);
  vdl_linkmap_remove (file);

  if (mapping)
    {
      void **i;
      for (i = vdl_list_begin (file->maps);
           i != vdl_list_end (file->maps);
           i = vdl_list_next (file->maps, i))
        {
          struct VdlFileMap *map = *i;
          struct VdlFileAddress *ret, *address = vdl_alloc_new (struct VdlFileAddress);
          address->key = map->mem_start_align;
          ret = vdl_rbfind (g_vdl.address_ranges, address);
          vdl_rberase (g_vdl.address_ranges, ret);
          vdl_alloc_delete (address);
          int status = system_munmap ((void *) map->mem_start_align,
                                      map->mem_size_align);
          if (status == -1)
            {
              VDL_LOG_ERROR ("unable to unmap map 0x%lx[0x%lx] for \"%s\"\n",
                             map->mem_start_align, map->mem_size_align,
                             file->filename);
            }
        }
    }

  if (vdl_context_empty (file->context))
    {
      vdl_context_delete (file->context);
    }

  vdl_list_delete (file->deps);
  vdl_list_delete (file->local_scope);
  vdl_list_delete (file->gc_symbols_resolved_in);
  vdl_alloc_free (file->name);
  vdl_alloc_free (file->filename);
  vdl_alloc_free (file->phdr);
  vdl_list_iterate (file->maps, vdl_alloc_free);
  vdl_list_delete (file->maps);
  rwlock_delete (file->lock);


  file->deps = 0;
  file->local_scope = 0;
  file->gc_symbols_resolved_in = 0;
  file->name = 0;
  file->filename = 0;
  file->context = 0;
  file->phdr = 0;
  file->phnum = 0;
  file->maps = 0;
  file->lock = 0;

  vdl_alloc_delete (file);
}
Пример #2
0
static void
file_delete (struct VdlFile *file, bool mapping)
{
  vdl_context_remove_file (file->context, file);

  if (mapping)
    {
      void **i;
      for (i = vdl_list_begin (file->maps); i != vdl_list_end (file->maps); i = vdl_list_next (i))
	{
	  struct VdlFileMap *map = *i;
	  int status = system_munmap ((void*)map->mem_start_align, 
				      map->mem_size_align);
	  if (status == -1)
	    {
	      VDL_LOG_ERROR ("unable to unmap map 0x%lx[0x%lx] for \"%s\"\n", 
			     map->mem_start_align, map->mem_size_align,
			     file->filename);
	    }
	}
    }

  if (vdl_context_empty (file->context))
    {
      vdl_context_delete (file->context);
    }

  vdl_list_delete (file->deps);
  vdl_list_delete (file->local_scope);
  vdl_list_delete (file->gc_symbols_resolved_in);
  vdl_alloc_free (file->name);
  vdl_alloc_free (file->filename);
  vdl_alloc_free (file->phdr);
  vdl_list_iterate (file->maps, vdl_alloc_free);
  vdl_list_delete (file->maps);


  file->deps = 0;
  file->local_scope = 0;
  file->gc_symbols_resolved_in = 0;
  file->name = 0;
  file->filename = 0;
  file->context = 0;
  file->phdr = 0;
  file->phnum = 0;
  file->maps = 0;

  vdl_alloc_delete (file);
}
Пример #3
0
uint32_t
vdl_int_hash (unsigned long i)
{
  char *str = vdl_utils_itoa (i);
  i = vdl_gnu_hash (str);
  vdl_alloc_free (str);
  return i;
}
Пример #4
0
void
vdl_utils_str_list_delete (struct VdlList *list)
{
  void **i;
  for (i = vdl_list_begin (list);
       i != vdl_list_end (list);
       i = vdl_list_next (list, i))
    {
      vdl_alloc_free (*i);
    }
  vdl_list_delete (list);
}
Пример #5
0
struct VdlList *
vdl_utils_splitpath (const char *value)
{
  struct VdlList *list = vdl_utils_strsplit (value, ':');
  void **i;
  for (i = vdl_list_begin (list);
       i != vdl_list_end (list);
       i = vdl_list_next (list, i))
    {
      if (vdl_utils_strisequal (*i, ""))
        {
          // the empty string is interpreted as '.'
          vdl_alloc_free (*i);
          i = vdl_list_erase (list, i);
          i = vdl_list_insert (list, i, vdl_utils_strdup ("."));
        }
    }
  return list;
}