Blame libglnx/glnx-backports.c

rpm-build c487f7
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
rpm-build c487f7
 *
rpm-build c487f7
 * Copyright (C) 2015 Colin Walters <walters@verbum.org>
rpm-build c487f7
 *
rpm-build c487f7
 * This program is free software: you can redistribute it and/or modify
rpm-build c487f7
 * it under the terms of the GNU Lesser General Public License as published
rpm-build c487f7
 * by the Free Software Foundation; either version 2 of the licence or (at
rpm-build c487f7
 * your option) any later version.
rpm-build c487f7
 *
rpm-build c487f7
 * This library is distributed in the hope that it will be useful,
rpm-build c487f7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build c487f7
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build c487f7
 * Lesser General Public License for more details.
rpm-build c487f7
 *
rpm-build c487f7
 * You should have received a copy of the GNU Lesser General
rpm-build c487f7
 * Public License along with this library; if not, write to the
rpm-build c487f7
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
rpm-build c487f7
 * Boston, MA 02111-1307, USA.
rpm-build c487f7
 */
rpm-build c487f7
rpm-build c487f7
#include "config.h"
rpm-build c487f7
rpm-build c487f7
#include "glnx-backports.h"
rpm-build c487f7
rpm-build c487f7
#if !GLIB_CHECK_VERSION(2, 44, 0)
rpm-build c487f7
gboolean
rpm-build c487f7
glnx_strv_contains (const gchar * const *strv,
rpm-build c487f7
                    const gchar         *str)
rpm-build c487f7
{
rpm-build c487f7
  g_return_val_if_fail (strv != NULL, FALSE);
rpm-build c487f7
  g_return_val_if_fail (str != NULL, FALSE);
rpm-build c487f7
rpm-build c487f7
  for (; *strv != NULL; strv++)
rpm-build c487f7
    {
rpm-build c487f7
      if (g_str_equal (str, *strv))
rpm-build c487f7
        return TRUE;
rpm-build c487f7
    }
rpm-build c487f7
rpm-build c487f7
  return FALSE;
rpm-build c487f7
}
rpm-build c487f7
rpm-build c487f7
gboolean
rpm-build c487f7
glnx_set_object (GObject **object_ptr,
rpm-build c487f7
                 GObject  *new_object)
rpm-build c487f7
{
rpm-build c487f7
  GObject *old_object = *object_ptr;
rpm-build c487f7
rpm-build c487f7
  if (old_object == new_object)
rpm-build c487f7
    return FALSE;
rpm-build c487f7
rpm-build c487f7
  if (new_object != NULL)
rpm-build c487f7
    g_object_ref (new_object);
rpm-build c487f7
rpm-build c487f7
  *object_ptr = new_object;
rpm-build c487f7
rpm-build c487f7
  if (old_object != NULL)
rpm-build c487f7
    g_object_unref (old_object);
rpm-build c487f7
rpm-build c487f7
  return TRUE;
rpm-build c487f7
}
rpm-build c487f7
#endif