summaryrefslogtreecommitdiffstats
path: root/src/plist.c
AgeCommit message (Collapse)AuthorFilesLines
2019-05-19Add plist_array_item_remove() to allow removing an array's child node ↵Gravatar Nikias Bassen1-0/+15
without relying on the index
2019-05-19plist_array_get_item_index(): return UINT_MAX instead of 0 when node can't ↵Gravatar Nikias Bassen1-1/+1
be found
2019-05-19Add index lookup table for large PLIST_ARRAY nodesGravatar Nikias Bassen1-11/+69
2019-05-16Ignore invalid input in plist_get_*_val() to prevent unnecessary assertionsGravatar Nikias Bassen1-19/+50
Also fixes #126 by skipping the strlen() in the assert() if for some reason NULL is returned as data
2019-01-21plist: Add iterator for #PLIST_ARRAY nodesGravatar Nikias Bassen1-4/+34
Similar to #PLIST_DICT, an iterator can now be used for #PLIST_ARRAY nodes. Get an iterator with plist_array_new_iter() and use plist_array_next_item() to iterate over the elements.
2018-12-23plist: Improve plist_dict_next_item() drastically by iterating on node list ↵Gravatar Nikias Bassen1-10/+8
directly As Xiao Deng pointed out in #131, plist_dict_next_item() was very inefficient. For each iteration, node_nth_child() was called with the iterator value, which would walk through the child node list on EVERY iteration. If the dictionary is large this makes things very slow. More than that, after reaching the key node the code was calling node_nth_child() AGAIN (with iterator value + 1) to reach the value node, which would walk through the node list once more. This commit changes the iterator to be a node_t pointer so that the iteration is done on the node list directly.
2018-12-10Remove node_iterator and operate on node list directly to improve memory usageGravatar Nikias Bassen1-7/+4
2017-02-07plist: Fix assert() to allow 16 or 8 byte integer sizes (16 bytes = unsigned ↵Gravatar Nikias Bassen1-1/+1
integer) Credit to Wang Junjie <zhunkibatu@gmail.com> (#90) Credit to OSS-Fuzz
2017-02-05bplist: Add error/debug logging (only if configured with --enable-debug)Gravatar Nikias Bassen1-0/+4
This commit adds proper debug/error messages being printed if the binary plist parser encounters anything abnormal. To enable debug logging, libplist must be configured with --enable-debug, and the environment variable PLIST_BIN_DEBUG must be set to "1".
2016-11-27plist_copy: Duplicate hash tables when copying PLIST_DICT nodesGravatar Nikias Bassen1-5/+15
2016-11-18Improve plist_dict_set_item performance for large dictionaries with hash tableGravatar Nikias Bassen1-12/+75
2016-10-22Remove libxml2 dependency in favor of custom XML parsingGravatar Nikias Bassen1-15/+71
2016-09-19Change internal storage of PLIST_DATE values from struct timeval to doubleGravatar Nikias Bassen1-22/+11
This removes the timeval union member from the plist_data_t structure. Since struct timeval is 2x64bit on 64bit platforms this member unnecessarily grew the union size to 16 bytes while a size of 8 bytes is sufficient. Also, on 32bit platforms struct timeval is only 2x32bit of size, limiting the range of possible time values. In addition the binary property list format also stores PLIST_DATE nodes as double.
2016-09-08Make sure plist_cleanup() symbol is actually publicGravatar Martin Szulecki1-1/+1
2016-06-29xplist: Plug memory leak when converting PLIST_UID nodes to XMLGravatar Nikias Bassen1-1/+1
In node_to_xml nodes of type PLIST_UID are temporarily converted to a PLIST_DICT for an appropriate XML output. Therefore a PLIST_KEY and a PLIST_UINT node is created and inserted into the PLIST_DICT node. Upon completion, the child nodes of the PLIST_DICT node are detached from the original node and freed, however the data of the child nodes - the key string and the uint value - are not. This commit fixes it.
2016-06-29plist_data_compare: Make sure to compare the node sizes for integer nodesGravatar Nikias Bassen1-0/+2
Without this check, e.g. the values -1 and 18446744073709551615 would yield in a match, since the comparison will just compare the uint64_t values. However, any value >= 9223372036854775808 and <= 18446744073709551615 is stored as a 128 bit value in binary plist format to make sure it is recognized as an unsigned value. We store it internally as a uint64_t value, but we set the size to 16 vs. 8 accordingly; so this commit will make sure the binary plist optimization will not re-use matching uint64_t values of actually mismatching signed/unsigned values.
2016-05-12Implement plist_from_memory()Gravatar Christophe Fergeau1-0/+15
Rather than having everyone reimplement binary/XML plist detection by looking at the first bytes of the plist content, it's better to do this detection in libplist and hide that internal detail from library users.
2016-05-12Add plist_is_binary()Gravatar Christophe Fergeau1-0/+9
It can be useful if one needs to know what type of plist a memory buffer contains.
2016-04-20Move libxml cleanup code to a plist_cleanup methodGravatar Frederik Carlier1-0/+18
2015-01-23Update and correct some copyright header commentsGravatar Martin Szulecki1-1/+3
2014-10-03Avoid exporting non-public symbolsGravatar Nikias Bassen1-48/+48
2014-05-20Removed plist_set_type() as it should not be used.Gravatar Nikias Bassen1-30/+0
2014-05-20Rename "index" variable as it shadows global declaration on older systemsGravatar Martin Szulecki1-2/+2
2014-04-02Simplify plist_dict_merge() after plist_dict_set_item() API changeGravatar Nikias Bassen1-3/+0
2014-03-19deprecated plist_dict_insert_item in favor of plist_dict_set_itemGravatar Nikias Bassen1-6/+1
2014-03-19plist_dict_set_item: insert key/value pair if key not already presentGravatar Nikias Bassen1-10/+11
2013-12-13add new plist_dict_merge() functionGravatar Nikias Bassen1-0/+27
2012-09-16plist_data_compare: for PLIST_DATA, compare length before accessing dataGravatar Nicolás Alvarez1-0/+2
2012-09-16implemented handling of UID keyed encoding typeGravatar Nikias Bassen1-0/+27
2012-04-24fix plist_dict_set_item() and plist_array_set_item()Gravatar Nikias Bassen1-9/+17
2011-05-27Make libplist glib freeGravatar Nikias Bassen1-43/+58
2010-01-21Fix some warningsGravatar Jonathan Beck1-34/+2
2009-11-19don't leak GNodes in plist_freeGravatar Christophe Fergeau1-1/+1
Before recursing over its children, plist_free_node started by detaching the current GNode from its parent which means that calling g_node_destroy on the root of the tree was freeing only the top-level GNode while what was intended was to free the whole tree. Don't leak memory by not detaching children GNodes from their parents so that g_node_destroy on the toplevel GNode can clean everything.
2009-11-19add missing break; in switch statementGravatar Christophe Fergeau1-0/+2
The 2nd missing break was harmless since it fell through the default: case which has a break, but it makes things more robust if we were ever to add new cases to this switch. The 1st missing break; was causing warnings in valgrind since we ended up calling strdup on a memory zone not containing a \0 character.
2009-11-10Remove deprecated functions from API.Gravatar Jonathan Beck1-189/+0
2009-10-28Format sources to ANSI style using AStyle (astyle --style=ansi).Gravatar Jonathan Beck1-579/+633
2009-10-28Fix build for MSVC9.Gravatar Jonathan Beck1-4/+7
2009-10-17Fixes for dates.Gravatar Jonathan Beck1-2/+2
2009-10-13Add path accessor util function.Gravatar Jonathan Beck1-25/+56
2009-10-11Fix dict length.Gravatar Jonathan Beck1-1/+1
2009-10-11Restore plist_dict_get_size function.Gravatar Jonathan Beck1-0/+9
2009-10-11Add function to change a node's type.Gravatar Jonathan Beck1-3/+35
2009-10-11Protect plist_free against NULL nodes.Gravatar Jonathan Beck1-2/+4
2009-10-11Fix dict iteration.Gravatar Jonathan Beck1-5/+14
2009-10-10Abstract iter base type.Gravatar Jonathan Beck1-5/+5
2009-10-10Fix dict iteration.Gravatar Jonathan Beck1-1/+1
2009-10-10Add dict iteration. Add functions to retrieve index and key from node.Gravatar Jonathan Beck1-5/+38
2009-10-10Reverse argument for dicts to make it clearer.Gravatar Jonathan Beck1-6/+7
2009-10-10Rework public API to make it more consistent.Gravatar Jonathan Beck1-112/+307
2009-07-18Fix copy_node to also copy key nodes.Gravatar Jonathan Beck1-1/+2