Re: Reffering to GArray as to an ordinar C-like array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi;

On 3 April 2015 at 12:35, Sergei Kolomeeyets <kolomeeyets@xxxxxxxxx> wrote:

> While trying to combine GSL and GLib functions in the same code I faced the
> following question. Can I refer to *GArray object like an ordinar C-like
> array?

No, you can't.

But you can use the `data` field, with some casting, and using the
`len` field to avoid going over the array bounds.

> gsl_fft_radix2_transform ( (double*) g_array_data, 1, 256);

The code below would look like:

  gsl_fft_radix2_transform ((double *) g_array_data->data, 1, 256);

But remember: operating on the underlying C array wrapped by a GArray
can be tricky because GArray grows and shrinks as needed. You should
never exceed the length of the GArray, and the code you're calling
should not try to modify the array data pointer itself (e.g. by
reallocating it).

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux