Commit Graph

85 Commits

Author SHA1 Message Date
Thomas Guillem 2484e2cbc7 vlc_arrays: add missing include
vlc_events.h will be removed.
vlc_events.h, that is included by vlc_input_item.h, includes vlc_common.h indirectly.
2023-12-25 13:40:11 +00:00
Francois Cartegnie cbccfbe45b vlc_array: constify count 2023-09-01 12:01:42 +00:00
Steve Lhomme e0e300609a vlc_array: use vlc_reallocarray for (re)allocation 2023-07-13 08:12:42 +00:00
Steve Lhomme 064d60406c vlc_arrays: move ARRAY_SIZE in vlc_common
It's a common C helper, not specific to VLC arrays.
2023-05-04 10:00:11 +00:00
Steve Lhomme 5363279805 remove the $Id$ in the source code 2019-01-17 12:21:18 +01:00
Romain Vimont 65366bd416 vlc_arrays: make "pos" expansion-safe
In a call to ARRAY_INSERT(array, elem, index + 1), "-pos" was expanded
to "-index + 1" instead of "-(index + 1)", leading to surprising results
and crashes.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
2018-08-29 12:07:19 +02:00
Romain Vimont 0393082816 vlc_arrays: avoid variable shadowing warnings
Make the variable name depend on "item" to avoid variable shadowing
warnings for nested loops (even if this specific shadowing is harmless).

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
2018-08-29 12:07:11 +02:00
Romain Vimont 53009d018b vlc_arrays: refactor foreach loop
Replace:

    FOREACH_ARRAY(item, array)
       // ...
    FOREACH_END()

by:

    ARRAY_FOREACH(item, array)
    {
        // ...
    }

Note that it is not possible to declare the iteration variable directly
anymore:

    ARRAY_FOREACH(void *item, array)

Instead, use:

    void *item;
    ARRAY_FOREACH(item, array)

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
2018-08-29 11:59:41 +02:00
Romain Vimont 1e61ff8382 vlc_arrays: add ARRAY_FIND()
TAB_FIND() was implemented, but not ARRAY_FIND(). It may be useful.

Signed-off-by: Thomas Guillem <thomas@gllm.fr>
2018-08-09 14:01:55 +02:00
Rémi Denis-Courmont 20b486fa9e include: move realloc_or_free() with realloc_down() 2018-02-11 21:35:16 +02:00
Rémi Denis-Courmont a1c3e136c4 Drop broken C99 support 2017-11-14 18:28:02 +02:00
Francois Cartegnie f49cd8802b vlc_arrays: split array_insert in checked and w/abort 2017-10-25 12:33:02 +02:00
Francois Cartegnie 9314bb489c vlc_arrays: split array_append in checked and w/abort 2017-10-25 12:33:02 +02:00
Francois Cartegnie 68588c1b84 vlc_arrays: add vlc_dictionary_is_empty
avoids walking every key/entry
2017-06-22 10:58:47 +02:00
Thomas Guillem cc3bf9f96f vlc_arrays: fix missing parenthesis 2017-05-30 10:57:38 +02:00
Rémi Denis-Courmont b59334a576 Remove (INSERT|REMOVE)_ELEM 2017-05-18 21:22:22 +03:00
Filip Roséen c882a670e4 vlc_arrays: rename reserved identifier
double underscore is reserved to the implementation according to both
the C and C++ ISO standards; as such we should not use such naming.

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
2017-05-18 19:16:14 +03:00
Francois Cartegnie 4cee7fe323 vlc_arrays: fix vlc_dictionary_has_key
broken untested function went under the radar
and is testing index from hash instead of key.
50% false positive due to hash % size pos.

fixes random behaviour in ttml #18250
and probably playlist fetcher, dbus control
2017-04-23 15:45:29 +02:00
Rémi Denis-Courmont 7e1aa4fb31 vlc_arrays: alias (INSERT|REMOVE)_ELEM to TAB_(INSERT|ERASE)
At this point, the two sets of helpers did essentially the same thing.
The only difference was that REMOVE_ELEM systematically shrinks the
table allocation, while TAB_ERASE waits for the table to become empty.
2017-02-21 22:00:28 +02:00
Rémi Denis-Courmont b866f51909 arrays: fix bogus cast in TAB_INSERT and TAB_ERASE
The cast, which is from the original stream output chain mega-patch,
assumed that all pointer types have same representation - which is
usually true. But it also assumed that tables would only contain
pointers; this might have been true back then, but it no longer is.
2017-02-21 21:53:15 +02:00
Filip Roséen 209ee554c4 vlc_arrays: remove vlc_array_{new, destroy}
These functions are no longer necessary nor used; future
implementations shall use vlc_array_init and vlc_array_clear
respectively).

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
2017-02-21 21:29:14 +02:00
Rémi Denis-Courmont 7ecd9271af array: fix up types in vlc_array_*()
- use size_t, ssize_t,
 - handle const types where applicable.
2017-02-19 22:58:43 +02:00
Francois Cartegnie 53b76149dc vlc_arrays: mitigate bsearch signed overflow 2016-09-14 18:46:27 +02:00
Francois Cartegnie e617042467 vlc_arrays: split TAB_REMOVE 2016-02-13 15:35:23 +01:00
Rémi Duraffort aa1868c759 Fix sizeof mismatch (fix many cids) 2013-07-22 18:03:55 +02:00
Rémi Denis-Courmont aba4767f27 TAB_FIND/TAB_REMOVE: remove inner variable, improve expansion safety 2013-02-06 20:56:38 +02:00
Rémi Denis-Courmont 5bf7136dcf Remove work-around for antique versions of MSVC 2012-09-03 12:45:28 +03:00
Rémi Denis-Courmont a7b2dcf0ee Remove WinCE 2012-09-02 12:22:01 +03:00
Jean-Paul Saman fd67d7f867 include/vlc_arrays.h: use unlikely() 2012-05-03 13:16:51 +02:00
Jean-Paul Saman 0dd0a8d44c vlc_arrays.h: check malloc return value. 2012-05-02 15:09:40 +02:00
Casian Andrei 308259d1ab Create a has_key function for a vlc dictionary
Signed-off-by: Ilkka Ollakka <ileoo@videolan.org>
2012-02-29 08:26:25 +02:00
Jean-Baptiste Kempf 36ab287e77 LGPL
Re-license almost all of libVLC and libVLCcore to LGPLv2.1+

This move was authorized by the developers, either:
 - by e-mail,
 - by vote at the VideoLAN Dev Days 2011,
 - on the license website,
 - in a contract, oral or written.
No objection was raised, so far.

The developers agreeing are:
  Justus Piater
  Alexis Ballier
  Alexander Bethke
  Mohammed Adnène Trojette
  Alex Converse
  Alexey Sokolov
  Alexis de Lattre
  Andre Pang
  Anthony Loiseau
  Cyril Deguet
  André Weber
  Boris Dorès
  Brieuc Jeunhomme
  Benjamin Drung
  Hugo Beauzée-Luyssen
  Benoit Steiner
  Benjamin Pracht
  Bernie Purcell
  Przemyslaw Fiala
  Arnaud de Bossoreille de Ribou
  Brad Smith
  Nick Briggs
  Christopher Rath
  Christophe Courtaut
  Christopher Mueller
  Clement Chesnin
  Andres Krapf
  Damien Fouilleul
  David Flynn
  Sebastien Zwickert
  Antoine Cellerier
  Jérôme Decoodt
  Jérome Decoodt
  Dylan Yudaken
  Eduard Babayan
  Eugenio Jarosiewicz
  Elliot Murphy
  Eric Petit
  Erwan Tulou
  Etienne Membrives
  Ludovic Fauvet
  Fabio Ritrovato
  Tobias Güntner
  Jakub Wieczorek
  Frédéric Crozat
  Francois Cartegnie
  Laurent Aimar
  Florian G. Pflug
  Felix Paul Kühne
  Frank Enderle
  Rafaël Carré
  Simon Latapie
  Gildas Bazin
  Geoffroy Couprie
  Julien / Gellule
  Gildas Bazin
  Arnaud Schauly
  Toralf Niebuhr
  Vicente Jimenez Aguilar
  Derk-Jan Hartman
  Henri Fallon
  Ilkka Ollakka
  Olivier Teulière
  Rémi Duraffort
  Jakob Leben
  Jean-Baptiste Kempf
  Jean-Paul Saman
  Jean-Philippe Grimaldi
  Jean-François Massol
  Gaël Hendryckx
  Jakob Leben
  Jean-Marc Dressler
  Jai Menon
  Johan Bilien
  Johann Ransay
  Joris van Rooij
  JP Dinger
  Jean-Philippe André
  Adrien Grand
  Juha Jeronen
  Juho Vähä-Herttua
  Kaarlo Raiha
  Kaarlo Raiha
  Kamil Baldyga
  Keary Griffin
  Ken Self
  KO Myung-Hun
  Pierre Ynard
  Filippo Carone
  Loïc Minier
  Luca Barbato
  Lucas C. Villa Real
  Lukas Durfina
  Adrien Maglo
  Marc Ariberti
  Mark Lee
  Mark Moriarty
  Martin Storsjö
  Christophe Massiot
  Michel Kaempf
  Marian Ďurkovič
  Mirsal Ennaime
  Carlo Calabrò
  Damien Lucas
  Naohiro Koriyama
  Basos G
  Pierre Baillet
  Vincent Penquerc'h
  Olivier Aubert
  Pankaj Yadav
  Paul Corke
  Pierre d'Herbemont
  Philippe Morin
  Antoine Lejeune
  Michael Ploujnikov
  Jean-Marc Dressler
  Michael Hanselmann
  Rafaël Carré
  Ramiro Polla
  Rémi Denis-Courmont
  Renaud Dartus
  Richard Shepherd
  Faustino Osuna
  Arnaud Vallat
  Rob Jonson
  Robert Jedrzejczyk
  Steve Lhomme
  Rocky Bernstein
  Romain Goyet
  Rov Juvano
  Sam Hocevar
  Martin T. H. Sandsmark
  Sebastian Birk
  Sébastien Escudier
  Vincent Seguin
  Fabio Ritrovato
  Sigmund Augdal Helberg
  Casian Andrei
  Srikanth Raju
  Hannes Domani
  Stéphane Borel
  Stephan Krempel
  Stephan Assmus
  Tony Castley
  Pavlov Konstantin
  Eric Petit
  Tanguy Krotoff
  Dennis van Amerongen
  Michel Lespinasse
  Can Wu
  Xavier Marchesini
  Sébastien Toque
  Christophe Mutricy
  Yoann Peronneau
  Yohann Martineau
  Yuval Tze
  Scott Caudle
  Clément Stenac

It is possible, that some minor piece of code was badly tracked, for
some reasons (SVN, mainly) or that some small developers did not answer.
However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3",
and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and
the very vast majority of developers have agreed (> 99.99% of the code,
> 99% of developers), we are fine here.
2011-11-27 22:54:33 +01:00
Rafaël Carré 4dac634850 vlc_arrays: remove unused macro _ARRAY_GROW
don't start variables with _, they have local scope anyway
2011-08-20 19:56:50 -04:00
Rafaël Carré b123950891 remove redundant TAB_APPEND_CPP 2011-08-20 19:56:22 -04:00
Hugo Beauzée-Luyssen a1a0cafb6c vlc_arrays: Adding a C++ helper to clean a container
Signed-off-by: Rémi Duraffort <ivoire@videolan.org>
2010-11-26 19:47:47 +01:00
Rémi Denis-Courmont f83fdcacb5 Expansion safety 2010-07-19 19:59:31 +03:00
Rémi Denis-Courmont 4c8dc8e914 Abort if array allocation fails 2009-05-31 22:25:54 +03:00
Rémi Denis-Courmont 982400e1dc Error-proof REMOVE_ELEM 2009-05-24 21:10:38 +03:00
Laurent Aimar 37d45ebb7a Cosmetics + A calloc check. 2008-10-09 01:22:02 +02:00
Adrien Maglo 639eb0c5ab Redefine vlc_dictionary_clear() and vlc_dictionary_remove_value_for_key() Allow passing a pointer to a function and an opaque pointer in order to free the memory if the values of the dictionary contain allocated memory.
Signed-off-by: Rémi Duraffort <ivoire@videolan.org>
2008-10-05 21:44:46 +02:00
Rémi Duraffort 2909c5c31d Protect against bad use after a vlc_dictionary_clear. 2008-10-01 19:55:09 +02:00
Rémi Duraffort 05c8c0d916 vlc_array: Macro safety. 2008-09-26 22:59:23 +02:00
Rémi Duraffort 2bb0711d59 vlc_array: macro safety. 2008-09-26 21:35:46 +02:00
Rémi Denis-Courmont 4edec0d684 FOREACH_ARRAY: expansion safety 2008-09-14 13:10:30 +03:00
Jean-Paul Saman ebd800345f Add a bunch of \file doxygen comments 2008-08-13 22:22:58 +08:00
Rémi Denis-Courmont c0f4bfc5d8 Headers: use non-reserved identifiers for multi-inclusion protection 2008-08-11 19:34:48 +03:00
Rémi Denis-Courmont fbb8255dcf Remove __LIBVLC__ test 2008-06-06 19:07:55 +03:00
Rémi Denis-Courmont 900ea6ff82 Do not use assert in public headers 2008-05-26 19:19:42 +03:00
Pierre d'Herbemont 449fd28aaf Replace vlc_bool_t by bool, VLC_TRUE by true and VLC_FALSE by false.
This improves readability a lot and prevent us from reinventing the wheel.
2008-04-14 02:02:22 +02:00
Sam Hocevar 5122c9d9e9 Various spelling fixes. 2008-03-21 21:25:49 +00:00