1. [GEN]: peek and multiple indirection

Hello all fellow euphorians,

i seem to have a problem with pointers and `peek( )`. I have this variabl=
e
this is a pointer to a pointer:

// in C

int **multi_indirec;

Back to euphoria. So i have this atom which is a pointer to a pointer. I
tried to `peek( )` this atom so i have just a pointer. This caused a
seqmentation fault. Is this Euphoria's fault or that of my code? Is there=
 any
other way to access the value at the end of the pointer chain?

ex

atom ptr_to_ptr, ptr, value

-- variables now have values/locations

ptr =3D peek( ptr_to_ptr ) -- segmentation fault is here
value =3D peek( { ptr, length( ptr ) } )


What is wrong? Have i missed some basic part of Euphoria that allows for =
this
or what?

Any help is appreciated. Thanks in advance.

--=20
evil, corruption and bad taste
  ^cense

new topic     » topic index » view message » categorize

2. Re: [GEN]: peek and multiple indirection

Cense wrote...

> i seem to have a problem with pointers and `peek( )`. I have this variable
> this is a pointer to a pointer:
>
> // in C
>
> int **multi_indirec;
>
> Back to euphoria. So i have this atom which is a pointer to a pointer. I
> tried to `peek( )` this atom so i have just a pointer. This caused a
> seqmentation fault. Is this Euphoria's fault or that of my code? Is there
any
> other way to access the value at the end of the pointer chain?
>
> ex
>
> atom ptr_to_ptr, ptr, value
>
> -- variables now have values/locations
>
> ptr = peek( ptr_to_ptr ) -- segmentation fault is here
> value = peek( { ptr, length( ptr ) } )

Hi Cense

I'm not sure, but is it possible that you are only peeking the first byte of
the "location"

I would imagine that your pointer is at least a 32-bit address??

Perhaps change....

ptr = peek( ptr_to_ptr )    <--- returns only one byte of your complete
address

to

ptr = peek4u(ptr_to_ptr)



Good luck!

Mark

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu