hash_case_string (id, 0), &named_handles)
if (!strcasecmp (id, handle->id))
{
- handle->ref_cnt++;
- return handle;
+ return fh_ref (handle);
}
return NULL;
if (id != NULL)
{
- assert (fh_from_id (id) == NULL);
hmap_insert (&named_handles, &handle->name_node,
hash_case_string (handle->id, 0));
- handle->ref_cnt++;
}
return handle;
struct file_handle *
fh_inline_file (void)
{
- fh_ref (inline_file);
return inline_file;
}
struct file_handle *
fh_get_default_handle (void)
{
- return default_handle ? fh_ref (default_handle) : fh_inline_file ();
+ return default_handle ? default_handle : fh_inline_file ();
}
/* Sets NEW_DEFAULT_HANDLE as the default handle. */
{
assert (new_default_handle == NULL
|| (new_default_handle->referent & (FH_REF_INLINE | FH_REF_FILE)));
- if (default_handle != NULL)
+ if (default_handle != NULL && default_handle != inline_file)
fh_unref (default_handle);
default_handle = new_default_handle;
if (default_handle != NULL)