summaryrefslogtreecommitdiff
path: root/src/cairo-array.c
Commit message (Collapse)AuthorAgeFilesLines
* Make cairo_tag_begin/end work correctly in groupsAdrian Johnson2023-04-181-0/+36
| | | | Fixes #508
* doc: Fix the gtk-doc syntax of internal symbolsKhaled Hosny2023-02-021-5/+9
| | | | To stop gtk-doc from listing them as undocumented.
* fixed some multiplications prone to overflowing their typeAyman El Didi2022-02-191-4/+4
| | | | | | | | | | | | | | | In a couple of instances, code is present where two numbers are being multiplied in a type like unsigned int, but immediately being casted to a wider type like size_t. This means, although the result can be any size_t value, the multiplication can potentially overflow before it's used because unsigned int has a smaller range of values. In another more niche case, I also cast to size_t before multiplying a signed integer, since the result is immediately used as an argument to memcpy, which would give memory corruption if the value was negative anyway.
* fixed some comparisons between signed and unsigned integersAyman El Didi2022-02-181-3/+3
| | | | | | In some places, there were int variables being compared to unsigned ints when they would never take a negative value, exposing some edge cases that didn't need to be there.
* pdf: add support for object streams for PDF >= 1.5Adrian Johnson2021-07-261-0/+6
| | | | | | | | This allows all objects that were previously emitted uncompressed to be compressed into a an object stream. Currently only /Page, /Pages, and /Catalog have been converted to use object streams.
* Don't call _cairo_array_append_multiple with a zero count.Jonathan Kew2021-02-211-0/+5
| | | | | | | | | | | | The documentation for _cairo_array_append_multiple says "one or more items". If it is called with num_elements=0, it ends up calling _cairo_array_grow_by with num_elements=0, which if the array is currently empty (as here) leads to undefined behavior in _cairo_array_allocate in the line *elements = array->elements + array->num_elements * array->element_size; because it ends up trying to add 0 to a null pointer. C doesn't allow this. (UBSan flags this as "applying zero offset to null pointer".)
* Misc. typosluz.paz2019-01-311-1/+1
| | | | | | | Found via `codespell -i 3 -w -I ../cairo-word-whitelist.txt -L tim,ned,uint` Follow up of 12cb59be7da Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
* Avoid appending an empty slot to an user data array when user_data is NULL.江頭幸路2015-04-201-0/+3
| | | | | | | | | | | | | Otherwise, calling cairo_set_user_data(cr, key, 0, 0) many times causes a long user data array, almost all of whose slots are empty. It leads to unnecessarily much memory consumption and long execution time of cairo_set_user_data(cr, key, 0, 0) and cairo_get_user_data(cr, key) after it. This issue probably happens since the commit http://cgit.freedesktop.org/cairo/commit/?id=9341c254a Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* Introduce a new compositor architectureChris Wilson2011-09-121-5/+6
| | | | | | | | | | | | | | | | | | Having spent the last dev cycle looking at how we could specialize the compositors for various backends, we once again look for the commonalities in order to reduce the duplication. In part this is motivated by the idea that spans is a good interface for both the existent GL backend and pixman, and so they deserve a dedicated compositor. xcb/xlib target an identical rendering system and so they should be using the same compositor, and it should be possible to run that same compositor locally against pixman to generate reference tests. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> P.S. This brings massive upheaval (read breakage) I've tried delaying in order to fix as many things as possible but now this one patch does far, far, far too much. Apologies in advance for breaking your favourite backend, but trust me in that the end result will be much better. :)
* array: Fix commentAndrea Canciani2010-11-281-2/+2
| | | | | The comment was talking about using 0 as index, but was using "num_elements" instead.
* array: Cleanup typesAndrea Canciani2010-11-241-8/+11
| | | | | | | | | Const-ify where appropriate and make all index and element counts unsigned int. This is needed to enable accessing const cairo_array_t's without having to manually remove the const qualifier (which happens in the to-be-merged mesh pattern code, for example).
* array: Add read-only accessorAndrea Canciani2010-11-241-5/+46
| | | | | | | | | | | It is sometimes useful to read the elements of a const cairo_array_t, but it is currently only possible by ignoring the const qualifier. The _cairo_array_index_const function allows read-only access to the array elements. This is needed to enable accessing const cairo_array_t's without having to manually remove the const qualifier (which happens in the to-be-merged mesh pattern code, for example).
* array: Remove snapshot supportAndrea Canciani2010-11-241-52/+5
| | | | | | | | Array snapshots are not used anymore and just bloat the implementation of cairo_array_t. In particular, double indirection was needed to implement array snapshots, as explained in c78685399307431903613733ddc936a104376943.
* Fix typo in docsBenjamin Otte2010-05-051-1/+1
|
* Update FSF addressAndrea Canciani2010-04-271-1/+1
| | | | | | | | | | | I updated the Free Software Foundation address using the following script. for i in $(git grep Temple | cut -d: -f1 ) do sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i" done Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21356
* Move _cairo_error() to a standalone headerChris Wilson2010-01-221-0/+1
| | | | | A pending commit will want to include some utility code from cairo and so we need to extricate the error handling from the PLT symbol hiding.
* [surface] Speed up cairo_surface_get_mime_data().Chris Wilson2009-06-011-8/+0
| | | | | | | | The number of mime-types attached to a surface is usually small, typically zero. Therefore it is quicker to do a strcmp() against each key in the private mime-data array than it is to intern the string (i.e. compute a hash, search the hash table, and do a final strcmp).
* [memfault] Manually inject faults when using stack allocationsChris Wilson2009-04-231-0/+3
| | | | | | | | | | Ensure that no assumptions are made that a small allocation will succeed by manually injecting faults when we may be simply allocating from an embedded memory pool. The main advantage in manual fault injection is improved code coverage - from within the test suite most allocations are handled by the embedded memory pools.
* Fix a const warning in _cairo_user_data_array_foreach()Jeff Muizelaar2009-02-181-1/+1
| | | | | | _cairo_user_data_array_foreach() was taking a function with a void *key parameter instead of a const void *key to match cairo_user_data_slot_t.
* [surface] Separate the mime-data from the user-data.Chris Wilson2009-02-131-0/+36
| | | | | | | | | | | | | | | | | | Move the mime-data into its own array so that it cannot be confused with user-data and we do not need to hard-code the copy list during snapshotting. The copy-on-snapshotting code becomes far simpler and will accommodate all future mime-types. Keeping mime-data separate from user-data is important due to the principle of least surprise - the API is different and so it would be surprising if you queried for user-data and were returned an opaque mime-data pointer, and vice versa. (Note this should have been prevented by using interned strings, but conceptually it is cleaner to make the separation.) Also it aides in trimming the user data arrays which are linearly searched. Based on the original patch by Adrian Johnson: http://cgit.freedesktop.org/~ajohnson/cairo/commit/?h=metadata&id=37e607cc777523ad12a2d214708d79ecbca5b380
* Mark allocation failures as unlikely.Chris Wilson2008-11-291-2/+2
| | | | | Use the gcc likelihood annotation to indicate that allocation failures are extremely unlikely.
* Mark if(status) as being unlikely.Chris Wilson2008-11-291-3/+3
| | | | | The error paths should be hit very rarely during normal operation, so mark them as being unlikely so gcc may emit better code.
* [array] Rearrange user_data_fini() to optimize common case.Chris Wilson2008-10-301-6/+10
| | | | | Micro-optimisation to avoid the _cairo_array_index() for the common case of 0 elements.
* [array] Silence gtk-doc complaints.Chris Wilson2008-10-071-6/+20
| | | | | | gtk-doc fails make check for array as it insists that even the simplest functions must have a long description and cannot be entirely described by their arguments and return value.
* Fix newly detected doc syntax issuesBehdad Esfahbod2008-06-011-3/+3
|
* [cairo-array] Guard against integer overflow whilst growing the array.Chris Wilson2008-04-031-4/+8
| | | | | | Sanity check the arguments to _cairo_array_grow_by() such that the array size does not overflow, similar to the defensive checking of parameters to malloc.
* [doc] Stricter syntax check for type names, update testBehdad Esfahbod2008-01-281-1/+1
|
* [doc] Make sure all function names in docs are followed by ()Behdad Esfahbod2008-01-281-1/+1
|
* [doc] Make sure all type names in docs are prefixed by #Behdad Esfahbod2008-01-281-1/+1
|
* [doc] Make sure all macro names in docs are prefixed by %Behdad Esfahbod2008-01-281-3/+3
|
* [cairo-surface] Introduce _cairo_surface_create_in_error().Chris Wilson2008-01-161-2/+1
| | | | | Unexport all the static error surfaces and use a function to select the appropriate error surface for the status.
* [cairo-error] Clean up all the warnings and missing _cairo_error() calls.Chris Wilson2007-10-041-6/+3
| | | | | | | | | | | Every time we assign or return a hard-coded error status wrap that value with a call to _cairo_error(). So the idiom becomes: status = _cairo_error (CAIRO_STATUS_NO_MEMORY); or return _cairo_error (CAIRO_STATUS_INVALID_DASH); This ensures that a breakpoint placed on _cairo_error() will trigger immediately cairo detects the error.
* [malloc/error] Add call to _cairo_error() after a failed malloc.Chris Wilson2007-10-041-1/+5
| | | | | Blitz all allocations to ensure that they raise a _cairo_error(CAIRO_STATUS_NO_MEMORY) on failure.
* [malloc] Check for integer overflow when realloc'ing.Chris Wilson2007-10-041-2/+2
| | | | | Perform similar sanity checks to Vlad's _cairo_malloc_ab() but on the arguments to realloc instead.
* Spell check the docsBehdad Esfahbod2007-01-071-1/+1
|
* Add _cairo_array_size to allow querying the allocated sizeCarl Worth2006-09-071-0/+12
|
* Eliminate conditions checking for unsigned or enum values less than 0.Carl Worth2006-08-281-1/+1
|
* Add -Wsign-compare compiler flag and fix all warningsCarl Worth2006-07-281-3/+3
|
* Remove initial, final, and duplicate blank lines.Carl Worth2006-06-061-1/+0
| | | | | | This patch was produced by running git-stripspace on all *.[ch] files within cairo. Note that this script would have also created all the changes from the previous commits to remove trailing whitespace.
* Remove trailing whitespace from lines that look like comments.Carl Worth2006-06-061-16/+16
| | | | | | | | | | This patch was produced with the following (GNU) sed script: sed -i -r -e '/^[ \t]*\/?\*/ s/[ \t]+$//' run on all *.[ch] files within cairo, (though I manually excluded src/cairo-atsui-font.c which has a code line that appears as a comment to this script).
* PS: Add three new public functions for emitting DSC comments.Carl Worth2006-05-031-3/+1
| | | | | | | | | | | | | | | | | This commit adds the following new functions to the cairo-ps API: cairo_ps_surface_dsc_comment cairo_ps_surface_dsc_begin_setup cairo_ps_surface_dsc_begin_page_setup Many thanks are due to Michael Sweet who provided invaluble guidance during the design of this API. It is hoped that with this API in place, basically all printer control that is likely to be desired to be performed with cairo PostScript output is now possible. This commit augments the ps-features test to exercise the new API.
* Here is a cleaner implementation of the _cairo_array_t change which was ↵Carl Worth2005-12-211-8/+34
| | | | | | | previously committed inadvertently. Fix buggy implementation of _cairo_array_snapshot by changing array->elements to be a pointer to a pointer. This extra level of indirection allows the snapshot array to point to a pointer which will itself get changed when new storage is needed for a growing array. Previously, the snapshot would be left pointing at stale storage. Fix to call _cairo_array_index rather than grabbing array->elements directly and casting (which cast is now wrong with the change in implementation of array->index).
* Revert inadvertent commit (immediately previous).Carl Worth2005-12-211-36/+17
|
* Fix indentation.Carl Worth2005-12-211-17/+36
|
* Note that self-copy now works with the PS backend.Carl Worth2005-12-071-0/+36
| | | | | | | Add _cairo_array_init_snapshot and checks for is_snapshot throughout. Add a new surface->backend->snapshot function. Implement _cairo_meta_surface_snapshot and _cairo_meta_surface_acquire/release_source_image. Change _cairo_meta_surface_create to require the width and height in pixels to be used when replaying for purposed of _cairo_meta_surface_aquire_source_image. Track change in prototype of _cairo_meta_surface_create. Implement _cairo_ps_surface_snapshot by deferring down into _cairo_meta_surface_snapshot.
* Add new _cairo_array_allocate function for growing the array and getting a ↵Carl Worth2005-11-071-11/+35
| | | | | | | | | | pointer to the buffer of new data. This is intended to be used in place of the abuse of passing data=NULL to _cairo_array_append_multiple. Add new function to be used instead of the abuse of pasing data=NULL to cairo_pdf_ft_font_write. Just return a status now instead of a pointer to the written buffer, since cairo_pdf_ft_font_allocate_write_buffer should now be used instead when a pointer is needed. Switch to use cairo_pdf_ft_font_allocate_write_buffer. Fix use of uninitialized status value. initialization just to keep the compiler quiet about possibly uninitialized variables.
* Rename old, rarely used _cairo_array_append to _cairo_array_append_multiple. ↵Carl Worth2005-11-041-34/+62
| | | | | | | Add much more common _cairo_array_append. Fix both to return a cairo_status_t. Remove undocumented code to allow a non-copying append when elements is NULL, (let's not encourage unintialized data, shall we?) Cleanup to not rely on undocumented copy-avoidance in _cairo_array_append. Track change in number of arguments and return value of _cairo_array_append.
* Add documentation for all _cairo_array interface functions.Carl Worth2005-11-041-0/+73
|
* Add CAIRO_STATUS_INVALID_CONTENT, CAIRO_STATUS_INVALID_FORMAT, and ↵Carl Worth2005-07-271-0/+5
| | | | | | | | | | | CAIRO_STATUS_INVALID_VISUAL. Change functions to return type of void: cairo_scaled_font_extents cairo_surface_finish Add new functions to query object status: cairo_scaled_font_status cairo_surface_status Implementation of new error handling scheme for cairo_surface_t and cairo_scaled_font_t. Track change in return value of cairo_surface_finish.
* Fix name of _cairo_user_data_array_destroy to be _cairo_user_data_array_fini.Carl Worth2005-06-031-3/+3
|