AdgSegment

AdgSegment — A wrapper for CpmlSegment

Synopsis

typedef             AdgSegment;
AdgSegment *        adg_segment_deep_copy               (AdgSegment *segment,
                                                         const AdgSegment *src);
AdgSegment *        adg_segment_deep_dup                (const AdgSegment *segment);
AdgSegment *        adg_segment_dup                     (const AdgSegment *segment);

Object Hierarchy

  GBoxed
   +----AdgSegment

Description

AdgSegment is a wrapper in GType syntax of the CpmlSegment struct. Furthermore, some dynamic memory functions are provided, such as shallow and deep duplication functions.

Details

AdgSegment

typedef CpmlSegment AdgSegment;

Another name for CpmlSegment: check its documentation for the fields description and visibility details.

Since 1.0


adg_segment_deep_copy ()

AdgSegment *        adg_segment_deep_copy               (AdgSegment *segment,
                                                         const AdgSegment *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:

AdgSegment *backup;

backup = adg_segment_deep_dup(&segment);
// Now &segment can be modified
...
adg_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.

segment :

an AdgSegment structure

src :

the source segment to copy

Returns :

segment

Since 1.0


adg_segment_deep_dup ()

AdgSegment *        adg_segment_deep_dup                (const AdgSegment *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.

segment :

an AdgSegment structure

Returns :

a deep duplicate of segment: must be freed with g_free() when no longer needed.

Since 1.0


adg_segment_dup ()

AdgSegment *        adg_segment_dup                     (const AdgSegment *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 adg_segment_deep_dup() if it is required also the content duplication.

segment :

an AdgSegment structure

Returns :

a shallow duplicate of segment: must be freed with g_free() when no longer needed.

Since 1.0