Merge remote-tracking branch 'jolla/master' into feature/bullseye/1.0.50

This commit is contained in:
r3vn 2021-01-09 01:27:38 +01:00
commit 2a2f5c7095
12 changed files with 103 additions and 55 deletions

View File

@ -20,7 +20,7 @@ all: debug release pkgconfig
VERSION_MAJOR = 1 VERSION_MAJOR = 1
VERSION_MINOR = 0 VERSION_MINOR = 0
VERSION_RELEASE = 48 VERSION_RELEASE = 50
# Version for pkg-config # Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE) PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
@ -134,9 +134,9 @@ $(COVERAGE_OBJS) $(COVERAGE_STATIC_LIB): | $(COVERAGE_BUILD_DIR)
# Rules # Rules
# #
debug: $(DEBUG_STATIC_LIB) $(DEBUG_LIB) $(DEBUG_LINK) $(DEBUG_DEV_LINK) debug: $(DEBUG_STATIC_LIB) $(DEBUG_DEV_LINK)
release: $(RELEASE_STATIC_LIB) $(RELEASE_LIB) $(RELEASE_LINK) $(RELEASE_DEV_LINK) release: $(RELEASE_STATIC_LIB) $(RELEASE_DEV_LINK)
coverage: $(COVERAGE_STATIC_LIB) coverage: $(COVERAGE_STATIC_LIB)
@ -187,25 +187,23 @@ $(COVERAGE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(DEBUG_LIB): $(DEBUG_OBJS) $(DEBUG_LIB): $(DEBUG_OBJS)
$(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) -o $@ $(LD) $(DEBUG_OBJS) $(DEBUG_LDFLAGS) -o $@
ln -sf $(LIB) $(DEBUG_LINK)
$(RELEASE_LIB): $(RELEASE_OBJS) $(RELEASE_LIB): $(RELEASE_OBJS)
$(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) -o $@ $(LD) $(RELEASE_OBJS) $(RELEASE_LDFLAGS) -o $@
ln -sf $(LIB) $(RELEASE_LINK)
ifeq ($(KEEP_SYMBOLS),0) ifeq ($(KEEP_SYMBOLS),0)
$(STRIP) $@ $(STRIP) $@
endif endif
$(DEBUG_LINK): $(DEBUG_LINK): $(DEBUG_LIB)
ln -sf $(LIB) $@ ln -sf $(LIB) $@
$(RELEASE_LINK): $(RELEASE_LINK): $(RELEASE_LIB)
ln -sf $(LIB) $@ ln -sf $(LIB) $@
$(DEBUG_DEV_LINK): $(DEBUG_DEV_LINK): $(DEBUG_LINK)
ln -sf $(LIB_SYMLINK1) $@ ln -sf $(LIB_SYMLINK1) $@
$(RELEASE_DEV_LINK): $(RELEASE_DEV_LINK): $(RELEASE_LINK)
ln -sf $(LIB_SYMLINK1) $@ ln -sf $(LIB_SYMLINK1) $@
$(DEBUG_STATIC_LIB): $(DEBUG_OBJS) $(DEBUG_STATIC_LIB): $(DEBUG_OBJS)

12
debian/changelog vendored
View File

@ -1,3 +1,15 @@
libglibutil (1.0.50) unstable; urgency=low
* Added gutil_ptrv_length()
-- Slava Monich <slava.monich@jolla.com> Wed, 28 Oct 2020 17:59:10 +0200
libglibutil (1.0.49) unstable; urgency=low
* Added gutil_slice_free() macro
-- Slava Monich <slava.monich@jolla.com> Sat, 17 Oct 2020 01:01:25 +0300
libglibutil (1.0.48) unstable; urgency=low libglibutil (1.0.48) unstable; urgency=low
* Make library executable on rpm based systems * Make library executable on rpm based systems

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2014-2015 Jolla Ltd. * Copyright (C) 2014-2020 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com> * Copyright (C) 2014-2020 Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of BSD license as follows: * You may use this file under the terms of BSD license as follows:
* *
@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Jolla Ltd nor the names of its contributors * 3. Neither the names of the copyright holders nor the names of its
* may be used to endorse or promote products derived from this software * contributors may be used to endorse or promote products derived
* without specific prior written permission. * from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@ -48,6 +48,8 @@
# define G_PACKED # define G_PACKED
#endif #endif
#define gutil_slice_free(x) g_slice_free1(sizeof(*(x)), x) /* Since 1.0.49 */
#endif /* GUTIL_MACROS_H */ #endif /* GUTIL_MACROS_H */
/* /*

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2016-2019 Jolla Ltd. * Copyright (C) 2016-2020 Jolla Ltd.
* Copyright (C) 2016-2019 Slava Monich <slava.monich@jolla.com> * Copyright (C) 2016-2020 Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of BSD license as follows: * You may use this file under the terms of BSD license as follows:
* *
@ -117,6 +117,10 @@ gutil_bytes_equal_data(
GBytes* bytes, GBytes* bytes,
const GUtilData* data); /* Since 1.0.41 */ const GUtilData* data); /* Since 1.0.41 */
gsize
gutil_ptrv_length(
gconstpointer ptrv); /* Since 1.0.50 */
G_END_DECLS G_END_DECLS
#endif /* GUTIL_MISC_H */ #endif /* GUTIL_MISC_H */

View File

@ -1,8 +1,7 @@
Name: libglibutil Name: libglibutil
Version: 1.0.48 Version: 1.0.50
Release: 0 Release: 0
Summary: Library of glib utilities Summary: Library of glib utilities
Group: Development/Libraries
License: BSD License: BSD
URL: https://git.sailfishos.org/mer-core/libglibutil URL: https://git.sailfishos.org/mer-core/libglibutil
Source: %{name}-%{version}.tar.bz2 Source: %{name}-%{version}.tar.bz2
@ -25,7 +24,7 @@ This package contains the development library for %{name}.
%setup -q %setup -q
%build %build
make LIBDIR=%{_libdir} KEEP_SYMBOLS=1 release pkgconfig make %{_smp_mflags} LIBDIR=%{_libdir} KEEP_SYMBOLS=1 release pkgconfig
%install %install
rm -rf %{buildroot} rm -rf %{buildroot}

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2016-2018 Jolla Ltd. * Copyright (C) 2016-2020 Jolla Ltd.
* Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com> * Copyright (C) 2016-2020 Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of BSD license as follows: * You may use this file under the terms of BSD license as follows:
* *
@ -14,8 +14,8 @@
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its * 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from * contributors may be used to endorse or promote products derived
* this software without specific prior written permission. * from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@ -31,6 +31,7 @@
*/ */
#include <gutil_idlepool.h> #include <gutil_idlepool.h>
#include <gutil_macros.h>
#include <gutil_log.h> #include <gutil_log.h>
#include <glib-object.h> #include <glib-object.h>
@ -103,7 +104,7 @@ gutil_idle_pool_unref(
/* Clear pointer to the shared instance */ /* Clear pointer to the shared instance */
if (self->shared) *(self->shared) = NULL; if (self->shared) *(self->shared) = NULL;
gutil_idle_pool_drain(self); gutil_idle_pool_drain(self);
g_slice_free(GUtilIdlePool, self); gutil_slice_free(self);
} }
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2017 Jolla Ltd. * Copyright (C) 2017-2020 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com> * Copyright (C) 2017-2020 Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of BSD license as follows: * You may use this file under the terms of BSD license as follows:
* *
@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may * 3. Neither the names of the copyright holders nor the names of its
* be used to endorse or promote products derived from this software * contributors may be used to endorse or promote products derived
* without specific prior written permission. * from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@ -31,6 +31,7 @@
*/ */
#include "gutil_idlequeue.h" #include "gutil_idlequeue.h"
#include "gutil_macros.h"
#include "gutil_log.h" #include "gutil_log.h"
typedef struct gutil_idle_queue_item GUtilIdleQueueItem; typedef struct gutil_idle_queue_item GUtilIdleQueueItem;
@ -60,7 +61,7 @@ gutil_idle_queue_item_destroy(
if (item->destroy) { if (item->destroy) {
item->destroy(item->data); item->destroy(item->data);
} }
g_slice_free(GUtilIdleQueueItem, item); gutil_slice_free(item);
} }
static static
@ -151,7 +152,7 @@ gutil_idle_queue_unref(
GASSERT(q->ref_count > 0); GASSERT(q->ref_count > 0);
if (g_atomic_int_dec_and_test(&q->ref_count)) { if (g_atomic_int_dec_and_test(&q->ref_count)) {
gutil_idle_queue_cancel_all(q); gutil_idle_queue_cancel_all(q);
g_slice_free(GUtilIdleQueue, q); gutil_slice_free(q);
} }
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2017 Jolla Ltd. * Copyright (C) 2017-2020 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com> * Copyright (C) 2017-2020 Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of BSD license as follows: * You may use this file under the terms of BSD license as follows:
* *
@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may * 3. Neither the names of the copyright holders nor the names of its
* be used to endorse or promote products derived from this software * contributors may be used to endorse or promote products derived
* without specific prior written permission. * from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@ -32,6 +32,7 @@
#include "gutil_intarray.h" #include "gutil_intarray.h"
#include "gutil_ints.h" #include "gutil_ints.h"
#include "gutil_macros.h"
struct gutil_ints { struct gutil_ints {
const int* data; const int* data;
@ -134,7 +135,7 @@ gutil_ints_unref(
if (ints->free_func) { if (ints->free_func) {
ints->free_func(ints->user_data); ints->free_func(ints->user_data);
} }
g_slice_free(GUtilInts, ints); gutil_slice_free(ints);
} }
} }
} }
@ -157,7 +158,7 @@ gutil_ints_unref_to_data(
result = g_memdup(ints->data, ints->count * sizeof(int)); result = g_memdup(ints->data, ints->count * sizeof(int));
ints->free_func(ints->user_data); ints->free_func(ints->user_data);
} }
g_slice_free(GUtilInts, ints); gutil_slice_free(ints);
} else { } else {
result = g_memdup(ints->data, ints->count * sizeof(int)); result = g_memdup(ints->data, ints->count * sizeof(int));
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2016-2019 Jolla Ltd. * Copyright (C) 2016-2020 Jolla Ltd.
* Copyright (C) 2016-2019 Slava Monich <slava.monich@jolla.com> * Copyright (C) 2016-2020 Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of BSD license as follows: * You may use this file under the terms of BSD license as follows:
* *
@ -415,6 +415,22 @@ gutil_bytes_equal_data(
} }
} }
/* Calculates the length of NULL-terminated array of pointers */
gsize
gutil_ptrv_length(
gconstpointer ptrv) /* Since 1.0.50 */
{
if (G_LIKELY(ptrv)) {
gsize len = 0;
const gconstpointer* ptr = ptrv;
while (*ptr++) len++;
return len;
} else {
return 0;
}
}
/* /*
* Local Variables: * Local Variables:
* mode: C * mode: C

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2016 Jolla Ltd. * Copyright (C) 2016-2020 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com> * Copyright (C) 2016-2020 Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of BSD license as follows: * You may use this file under the terms of BSD license as follows:
* *
@ -13,9 +13,9 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Jolla Ltd nor the names of its contributors * 3. Neither the names of the copyright holders nor the names of its
* may be used to endorse or promote products derived from this software * contributors may be used to endorse or promote products derived
* without specific prior written permission. * from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@ -31,6 +31,7 @@
*/ */
#include "gutil_ring.h" #include "gutil_ring.h"
#include "gutil_macros.h"
#include "gutil_log.h" #include "gutil_log.h"
struct gutil_ring { struct gutil_ring {
@ -101,7 +102,7 @@ gutil_ring_unref(
} }
} }
g_free(r->data); g_free(r->data);
g_slice_free(GUtilRing, r); gutil_slice_free(r);
} }
} }
} }

View File

@ -31,6 +31,7 @@
*/ */
#include "gutil_strv.h" #include "gutil_strv.h"
#include "gutil_misc.h"
#include <stdlib.h> #include <stdlib.h>
@ -41,13 +42,7 @@ guint
gutil_strv_length( gutil_strv_length(
const GStrV* sv) const GStrV* sv)
{ {
if (G_LIKELY(sv)) { return (guint) gutil_ptrv_length(sv);
guint i = 0;
while (sv[i]) i++;
return i;
} else {
return 0;
}
} }
/** /**

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2016-2019 Jolla Ltd. * Copyright (C) 2016-2020 Jolla Ltd.
* Copyright (C) 2016-2019 Slava Monich <slava.monich@jolla.com> * Copyright (C) 2016-2020 Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of BSD license as follows: * You may use this file under the terms of BSD license as follows:
* *
@ -484,6 +484,23 @@ test_bytes_equal(
g_bytes_unref(bytes); g_bytes_unref(bytes);
} }
/*==========================================================================*
* ptrv
*==========================================================================*/
static
void
test_ptrv(
void)
{
static const gconstpointer ptrv0[] = { NULL };
static const gconstpointer ptrv1[] = { ptrv0, NULL };
g_assert_cmpuint(gutil_ptrv_length(NULL), == ,0);
g_assert_cmpuint(gutil_ptrv_length(ptrv0), == ,0);
g_assert_cmpuint(gutil_ptrv_length(ptrv1), == ,1);
}
/*==========================================================================* /*==========================================================================*
* Common * Common
*==========================================================================*/ *==========================================================================*/
@ -513,6 +530,7 @@ int main(int argc, char* argv[])
g_test_add_func(TEST_("bytes_concat"), test_bytes_concat); g_test_add_func(TEST_("bytes_concat"), test_bytes_concat);
g_test_add_func(TEST_("bytes_xor"), test_bytes_xor); g_test_add_func(TEST_("bytes_xor"), test_bytes_xor);
g_test_add_func(TEST_("bytes_equal"), test_bytes_equal); g_test_add_func(TEST_("bytes_equal"), test_bytes_equal);
g_test_add_func(TEST_("ptrv"), test_ptrv);
test_init(&test_opt, argc, argv); test_init(&test_opt, argc, argv);
return g_test_run(); return g_test_run();
} }