summaryrefslogtreecommitdiff
path: root/glib/gslice.c
Commit message (Collapse)AuthorAgeFilesLines
* gslice: Tag mem_error() as not returning because it abortsPhilip Withnall2022-11-181-1/+1
| | | | | | | This should quell some scan-build warnings about code breaking after returning from mem_error() in a weird state. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* glib: Add SPDX license headers automaticallyPhilip Withnall2022-05-181-0/+2
| | | | | | | | | | | | | | Add SPDX license (but not copyright) headers to all files which follow a certain pattern in their existing non-machine-readable header comment. This commit was entirely generated using the command: ``` git ls-files glib/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs' ``` Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #1415
* Fix global variable name hidden by local variables in glib/gslice.cLoic Le Page2022-02-181-34/+34
|
* Merge branch 'static-analysis' into 'main'Philip Withnall2021-10-181-1/+1
|\ | | | | | | | | fix issues found by svace static code analyzer See merge request GNOME/glib!2285
| * gslice: Fix page size being limited to int instead of gsizeEgor Bychin2021-10-151-1/+1
| |
* | Fix signedness warning in glib/gslice.cEmmanuel Fleury2021-10-121-1/+1
|/ | | | | | | glib/gslice.c: In function 'slice_config_init': glib/gslice.c:394:16: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' else if (len >= G_N_ELEMENTS (wvalue)) ^~
* docs: Break gtk-doc stanzas into paragraphsEmmanuele Bassi2021-08-021-6/+9
| | | | Keep the first paragraph short, to act as a summary.
* glib: Use g_memdup2() instead of g_memdup() in obvious placesPhilip Withnall2021-02-041-1/+1
| | | | | | | | | | | | | | | | | Convert all the call sites which use `g_memdup()`’s length argument trivially (for example, by passing a `sizeof()` or an existing `gsize` variable), so that they use `g_memdup2()` instead. In almost all of these cases the use of `g_memdup()` would not have caused problems, but it will soon be deprecated, so best port away from it In particular, this fixes an overflow within `g_bytes_new()`, identified as GHSL-2021-045 by GHSL team member Kevin Backhouse. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: GHSL-2021-045 Helps: #2319
* gslice: Inline win32 implementation of g_getenv() to avoid deadlockPhilip Withnall2020-10-151-0/+44
| | | | | | | | | | | | | The win32 implementation of `g_getenv()` uses GSlice (from within GQuark), which results in a deadlock when examining the `G_SLICE` environment variable. Fix that by inlining a basic implementation of `g_getenv()` at that call site. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #2225
* glib: Use g_getenv everywhere instead of getenvNirbheek Chauhan2020-07-231-1/+1
| | | | | | | `getenv()` doesn't work well on Windows, f.ex., it can't fetch env vars set with `SetEnvironmentVariable()`. This also means that it doesn't work at all when targeting UWP since that's the only way to set env vars in that case.
* tree: Fix various typos and outdated terminologyPhilip Withnall2020-06-121-3/+3
| | | | | | | | | | | | | | | | | | | | | | | This was mostly machine generated with the following command: ``` codespell \ --builtin clear,rare,usage \ --skip './po/*' --skip './.git/*' --skip './NEWS*' \ --write-changes . ``` using the latest git version of `codespell` as per [these instructions](https://github.com/codespell-project/codespell#user-content-updating). Then I manually checked each change using `git add -p`, made a few manual fixups and dropped a load of incorrect changes. There are still some outdated or loaded terms used in GLib, mostly to do with git branch terminology. They will need to be changed later as part of a wider migration of git terminology. If I’ve missed anything, please file an issue! Signed-off-by: Philip Withnall <withnall@endlessm.com>
* Replace fallthrough comments with G_GNUC_FALLTHROUGHTimm Bäder2020-03-041-0/+1
| | | | | It's safer to do it this way and since we have G_GNUC_FALLTHROUGH now, w e might as well replace the fallthrough comments.
* glib: Stop using g_get_current_time() in various placesPhilip Withnall2019-07-291-3/+2
| | | | | | Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #1438
* Annotate various types and macros as deprecatedPhilip Withnall2019-05-301-0/+2
| | | | | | | | | | | | | These have all been documented as deprecated for a long time, but we’ve never had a way to programmatically mark them as deprecated. Do that now. This is based on the list of deprecations from the reverted commit 80fcb1bc2. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #638
* gslice: Use a convenience macroPeter Bloomfield2019-04-031-4/+2
| | | | | | | In magazine_cache_trim(), use the recent G_APPROX_VALUE macro to decide when to trim the magazine chain. See <URL:https://gitlab.gnome.org/GNOME/glib/commit/fad04d2e18832106ecb4b9f04ae3bfdbcacc9053#note_471824>.
* Fixing signedness warning in glib/gslice.cEmmanuel Fleury2019-03-171-1/+4
| | | | | | | | | | | | In file included from glib/glibconfig.h:9, from glib/gslice.c:20: glib/gslice.c: In function ‘magazine_cache_trim’: glib/gmacros.h:354:25: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits] #define ABS(a) (((a) < 0) ? -(a) : (a)) ^ glib/gslice.c:643:10: note: in expansion of macro ‘ABS’ while (ABS (stamp - magazine_chain_uint_stamp (current)) >= allocator->config.working_set_msecs) ^~~
* gthread: Add g_private_set_alloc0() internal convenience APIPhilip Withnall2019-01-071-2/+2
| | | | | | | | | | | | This is a wrapper around g_private_set() which allocates the desired amount of memory for the caller and calls g_private_set() on it. This is intended to make it easier to suppress Valgrind warnings about leaked memory, since g_private_set() is typically used to make one-time per-thread allocations. We can now just add a blanket suppression rule for any allocations inside g_private_set_alloc0(). Signed-off-by: Philip Withnall <withnall@endlessm.com>
* Remove posix_memalign() checks for an old glibc bugChristoph Reiter2018-05-311-10/+5
| | | | | | | | | | | POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS was added in https://bugzilla.gnome.org/show_bug.cgi?id=328254 to work around a glibc bug where it wrongly checked the size argument to be a power of two instead of the alignment. This was fixed in glibc in https://sourceware.org/git/?p=glibc.git;a=commit;h=b2bffca2e3b59dd882039e3b0ab835d127bdaf7a about 16 years ago.
* Fix Windows build errors in valgrind.hXavier Claessens2018-05-281-1/+3
| | | | | | | | | | | valgrind.h is a verbatim copy taken from Valgrind project. Previously that file had local changes that got dropped by last update. To avoid regressing again, do not edit valgrind.h anymore and instead add a gvalgrind.h wrapper that gets included instead. This fix 2 errors: - uintptr_t is not defined when including valgrind.h on mingw. - MSVC compiler is not supported on amd64-Win64 platform.
* gslice: Use g_fprintf() instead of fprintf()Xavier Claessens2018-05-261-10/+11
| | | | | | | G_GSIZE_FORMAT and friends cannot always be used with fprintf(), they require gnu/C99 implementation. https://bugzilla.gnome.org/show_bug.cgi?id=796283
* ci: fix warnings and enable --werror for the mingw buildChristoph Reiter2018-04-251-0/+6
| | | | | | | | | | | | | Fix various warnings regarding unused variables, duplicated branches etc by adjusting the ifdeffery and some missing casts. gnulib triggers -Wduplicated-branches in one of the copied files, disable as that just makes updating the code harder. The warning indicating missing features are made none fatal through pragmas. They still show but don't abort the build. https://bugzilla.gnome.org/show_bug.cgi?id=793729
* docs: add missing '*' chars at start of doc-commentsStefan Sauer2017-11-121-1/+1
|
* docs: Fix a typo in the GSlice documentationPhilip Withnall2017-10-111-8/+8
| | | | | | And in a few of its variable names. s/adress/address/. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* gslice: Fix inline delarations in GSlicePhilip Withnall2017-08-031-4/+9
| | | | | | | Accidentally introduced in commit 5cddde1fb2b8466d8104595008eafabd0728de5d. Signed-off-by: Philip Withnall <withnall@endlessm.com>
* Consistently save errno immediately after the operation setting itPhilip Withnall2017-08-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Prevent the situation where errno is set by function A, then function B is called (which is typically _(), but could be anything else) and it overwrites errno, then errno is checked by the caller. errno is a horrific API, and we need to be careful to save its value as soon as a function call (which might set it) returns. i.e. Follow the pattern: int errsv, ret; ret = some_call_which_might_set_errno (); errsv = errno; if (ret < 0) puts (strerror (errsv)); This patch implements that pattern throughout GLib. There might be a few places in the test code which still use errno directly. They should be ported as necessary. It doesn’t modify all the call sites like this: if (some_call_which_might_set_errno () && errno == ESOMETHING) since the refactoring involved is probably more harmful than beneficial there. It does, however, refactor other call sites regardless of whether they were originally buggy. https://bugzilla.gnome.org/show_bug.cgi?id=785577
* glib/: LGPLv2+ -> LGPLv2.1+Sébastien Wilmet2017-05-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All glib/*.{c,h} files have been processed, as well as gtester-report. 12 of those files are not licensed under LGPL: gbsearcharray.h gconstructor.h glibintl.h gmirroringtable.h gscripttable.h gtranslit-data.h gunibreak.h gunichartables.h gunicomp.h gunidecomp.h valgrind.h win_iconv.c Some of them are generated files, some are licensed under a BSD-style license and win_iconv.c is in the public domain. Sub-directories inside glib/: deprecated/: processed in a previous commit glib-mirroring-tab/: already LGPLv2.1+ gnulib/: not modified, the code is copied from gnulib libcharset/: a copy pcre/: a copy tests/: processed in a previous commit https://bugzilla.gnome.org/show_bug.cgi?id=776504
* glib: Add missing (nullable) and (optional) annotationsPhilip Withnall2015-11-071-6/+32
| | | | | | | | | | | | | | | | | | Add various (nullable) and (optional) annotations which were missing from a variety of functions. Also port a couple of existing (allow-none) annotations in the same files to use (nullable) and (optional) as appropriate instead. Secondly, add various (not nullable) annotations as needed by the new default in gobject-introspection of marking gpointers as (nullable). See https://bugzilla.gnome.org/show_bug.cgi?id=729660. This includes adding some stub documentation comments for the assertion macro error functions, which weren’t previously documented. The new comments are purely to allow for annotations, and hence are marked as (skip) to prevent the symbols appearing in the GIR file. https://bugzilla.gnome.org/show_bug.cgi?id=719966
* Revert "Bug 724590 - GSlice slab_stack corruption"Ryan Lortie2014-04-161-2/+1
| | | | This reverts commit c49ec3c8d7a90589308ce1b87a92bc627335ffd2.
* Bug 724590 - GSlice slab_stack corruptionJohn Ralls2014-04-151-1/+2
| | | | | Dereference allocation->contention_counters before trying to take the address of an element.
* docs: let go of &ast;Matthias Clasen2014-02-141-6/+6
| | | | | | Since we are no longer using sgml mode, using /&ast; &ast;/ to escape block comments inside examples does not work anymore. Switch to using line comments with //
* Eradicate links and xrefsMatthias Clasen2014-02-081-20/+13
| | | | These are all replaced by markdown ref links.
* Docs: replace <literal> by `Matthias Clasen2014-02-061-10/+10
|
* Convert external links to markdown syntaxMatthias Clasen2014-02-051-2/+4
|
* Annotate all examples with their languageMatthias Clasen2014-02-011-2/+2
| | | | The C ones, at least.
* Docs: Convert examples to |[ ]|Matthias Clasen2014-01-311-14/+11
|
* Updated FSF's addressDaniel Mustieles2014-01-311-3/+1
|
* Docs: don't use <footnote>Matthias Clasen2014-01-301-4/+3
| | | | It basically does not work in the HTML output.
* Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIXDan Winship2013-11-201-1/+1
| | | | | | | | | | | | | | | In Windows development environments that have it, <unistd.h> is mostly just a wrapper around several other native headers (in particular, <io.h>, which contains read(), close(), etc, and <process.h>, which contains getpid()). But given that some Windows dev environments don't have <unistd.h>, everything that uses those functions on Windows already needed to include the correct Windows header as well, and so there is never any point to including <unistd.h> on Windows. Also, remove some <unistd.h> includes (and a few others) that were unnecessary even on unix. https://bugzilla.gnome.org/show_bug.cgi?id=710519
* Require C90 complianceDan Winship2013-11-201-10/+4
| | | | | | | | | | | | | | | | | | | Assume all supported platforms implement C90, and therefore they (correctly) implement atexit(), memmove(), setlocale(), strerror(), and vprintf(), and have <float.h> and <limits.h>. (Also remove the configure check testing that "do ... while (0)" works correctly; the non-do/while-based version of G_STMT_START and G_STMT_END was removed years ago, but the check remained. Also, remove some checks that configure.ac claimed were needed for libcharset, but aren't actually used.) Note that removing the g_memmove() function is not an ABI break even on systems where g_memmove() was previously not a macro, because it was never marked GLIB_AVAILABLE_IN_ALL or listed in glib.symbols, so it would have been glib-internal since 2004. https://bugzilla.gnome.org/show_bug.cgi?id=710519
* gslice: don't misuse g_mutex_init()Ryan Lortie2013-11-061-2/+0
| | | | | | We were using g_mutex_init() to initialise a pair of mutexes in static storage, but we should only do that for mutexes that are part of allocated structures.
* gslice: disable by default under valgrindRyan Lortie2013-04-221-0/+13
| | | | | | | | | | | | | | | | | | | | | | | All experienced GLib hackers know that G_SLICE=always-malloc is absolutely essential when valgrinding but many users of GLib don't know about this and get hit pretty hard when valgrinding their programs. When initialising gslice, add a check to see if we are running under valgrind and disable ourselves if we are. We only do the check in the case that G_SLICE= was not specified in the environment, so setting it to an empty string will prevent this default behaviour. I considered modifying gslice to use the VALGRIND_MALLOCLIKE_BLOCK client request in all cases in order to just mark the blocks properly but these calls are not free and gslice is pretty hyper-optimised. It's easier to just disable gslice completely and this way we only have to do one check during startup. It's also theoretically possible that someone might want to use valgrind to debug gslice, in which case the extra annotations would probably cause quite a lot of difficulty. https://bugzilla.gnome.org/show_bug.cgi?id=698595
* comments/docs: Fix couple of typosRavi Sankar Guntur2012-01-281-2/+2
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=668857
* Move slice and hook docs inlineMatthias Clasen2011-11-141-0/+255
|
* Cleanups to debug env var handlingMatthias Clasen2011-11-121-30/+18
|
* Move GTrashStack out of gutils.[hc]Matthias Clasen2011-10-161-0/+1
| | | | | Reducing the mess in gutils, and moving docs inline at the same time. Double win.
* Move environment-related functions into their own filesMatthias Clasen2011-10-151-1/+19
| | | | | | | | gutils.[hc] is a bit of a grab bag, so lets start cleaning things up by moving all the environment-related functions into separate genviron.[hc] files. The private _g_getenv_nomalloc has been moved to its sole caller.
* gslice: stop using ctorsRyan Lortie2011-10-041-6/+21
| | | | | | | | | | | | | | | | We can't initialise gslice from a ctor because g_slice_set_config() must be called before gslice initialisation. Instead, do the initialisation in a threadsafe way from the initialisation function for the thread private data. This will only be called once per thread so the synchronisation doesn't pose a significant overhead here. Ensure that we try to grab the thread private data directly on entrance to g_slice_alloc() so that we force the initialisation to occur. Grabbing the private data is the common case anyway. https://bugzilla.gnome.org/show_bug.cgi?id=660887
* Deprecate g_thread_init()Ryan Lortie2011-10-041-3/+0
| | | | | | | Move the last few things that needed thread-safe initialisation to a global ctor. https://bugzilla.gnome.org/show_bug.cgi?id=660744
* locks: drop _INIT macrosRyan Lortie2011-10-021-1/+1
| | | | | | | | | All locks are now zero-initialised, so we can drop the G_*_INIT macros for them. Adjust various users around GLib accordingly and change the docs. https://bugzilla.gnome.org/show_bug.cgi?id=659866
* Stop dithering over GPrivateRyan Lortie2011-10-021-3/+1
| | | | | | | | | | | | | | Take out the half-private g_private_init() stuff and replace it with a G_PRIVATE_INIT macro that allows specifying a GDestroyNotify. Expose the GPrivate structure in a public header. Add a g_private_replace() to (sort of) match the functionality of g_static_mutex_set(). Improve the documentation. Deprecate g_private_new().