![]() |
![]() |
![]() |
CPML reference manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <cpml-1/cpml.h> CpmlPair * cpml_pair_dup (const CpmlPair *pair
); CpmlPrimitive * cpml_primitive_dup (const CpmlPrimitive *primitive
); CpmlPrimitive * cpml_primitive_deep_dup (const CpmlPrimitive *primitive
); CpmlSegment * cpml_segment_dup (const CpmlSegment *segment
); CpmlSegment * cpml_segment_deep_dup (const CpmlSegment *segment
); void cpml_segment_deep_copy (CpmlSegment *segment
,const CpmlSegment *src
);
These wrappers are supposed to make bindings development easier.
This file defines the wrappers and the functions needed for
implementing a GBoxed type, most notably the GBoxedCopyFunc
requested by g_boxed_type_register_static()
(the GBoxedFreeFunc
will usually be g_free()
).
CpmlPair * cpml_pair_dup (const CpmlPair *pair
);
Duplicates pair
.
|
an CpmlPair structure |
Returns : |
the duplicate of pair : must be freed with g_free() when no longer needed. [transfer full]
|
Since 1.0
CpmlPrimitive * cpml_primitive_dup (const CpmlPrimitive *primitive
);
Duplicates primitive
. This function makes a shallow duplication of
primitives
, that is the internal pointers of the resulting primitive
struct refer to the same memory as the original primitive
. Check
out cpml_primitive_deep_dup()
if it is required also the content
duplication.
|
an CpmlPrimitive structure |
Returns : |
a shallow duplicate of primitive : must be
freed with g_free() when no longer needed. [transfer full]
|
Since 1.0
CpmlPrimitive * cpml_primitive_deep_dup (const CpmlPrimitive *primitive
);
Duplicates primitive
. This function makes a deep duplication of
primitive
, that is it duplicates also the definition data (both
org
and data
).
Furthermore, the new segment
field will
point to a fake duplicated segment with only its first primitive
set (the first primitive of a segment should be a CPML_MOVE).
This is needed in order to let a CPML_CLOSE work as expected.
All the data is allocated in the same chunk of memory so freeing the returned pointer releases all the occupied memory.
|
an CpmlPrimitive structure |
Returns : |
a deep duplicate of primitive : must be
freed with g_free() when no longer needed. [transfer full]
|
Since 1.0
CpmlSegment * cpml_segment_dup (const CpmlSegment *segment
);
Duplicates segment
. This function makes a shallow duplication,
that is the internal pointers of the resulting segment struct
refer to the same memory as the original segment
. Check out
cpml_segment_deep_dup()
if it is required also the content
duplication.
|
an CpmlSegment structure |
Returns : |
a shallow duplicate of segment : must be freed with g_free() when no longer needed. [transfer full]
|
Since 1.0
CpmlSegment * cpml_segment_deep_dup (const CpmlSegment *segment
);
Duplicates segment
. This function makes a deep duplication,
that is it duplicates also the underlying data that defines
the segment. The path
field
is set to NULL
as data
is no
more referring to the original cairo path.
All the data is allocated in the same chunk of memory so freeing the returned pointer releases all the occupied memory.
|
an CpmlSegment structure |
Returns : |
a deep duplicate of segment : must be freed with g_free() when no longer needed. [transfer full]
|
Since 1.0
void cpml_segment_deep_copy (CpmlSegment *segment
,const CpmlSegment *src
);
Makes a deep copy of src
to segment
. For a shallow copy, check out
the cpml_segment_copy()
API provided by the CPML library.
This could seem a somewhat unusual operation because segment
should
be "compatible" with src
: it is expected that they have the same
num_data
value. Anyway, it is convenient
in some situation, such as when restoring the original data from a
deep duplicated source:
1 2 3 4 5 6 7 |
CpmlSegment *backup; backup = cpml_segment_deep_dup(&segment); // Now &segment can be modified ... cpml_segment_deep_copy(&segment, backup); g_free(backup); |
The struct fields of segment
are left untouched and used only to
check if it is compatible with src
.
|
an CpmlSegment structure |
|
the source segment to copy |
Since 1.0