[#16113] Strange idea... exporting from a scope — "Hal E. Fulton" <hal9000@...>

Hello...

33 messages 2001/06/01

[#16364] Re: Garbage Collection? — Michael Davis <mdavis@...>

Windows 2000 and linux (RedHat 6.2). I have run these tests on both OSs.

12 messages 2001/06/09

[#16400] Symbolic Computation III — Mathieu Bouchard <matju@...>

14 messages 2001/06/11

[#16502] Playing with Ruby Syntax (was: Initial thoughts about Ruby From a Smalltalk Programmer) — jweirich@...

Michael> Hi Everyone, I have to say I'm utterly fascinated by Ruby

9 messages 2001/06/15

[#16661] Problem running irb with Ruby 1.6.4 under FreeBSD 4.0 — Bob Alexander <balexander@...>

I've installed Ruby 1.6.4 on a FreeBSD 4.0 machine, and get the

11 messages 2001/06/20

[#16686] opening db files made by apache dbmmanage — Fritz Heinrichmeyer <fritz.heinrichmeyer@...>

14 messages 2001/06/21

[#16801] rb_define_class() vs Class.new() — Kero van Gelder <kero@...4050.upc-d.chello.nl>

Hi,

18 messages 2001/06/23
[#16802] Re: rb_define_class() vs Class.new() — ts <decoux@...> 2001/06/23

>>>>> "K" == Kero van Gelder <kero@d4050.upc-d.chello.nl> writes:

[#16841] RE: national characters is strings — "Aleksei Guzev" <aleksei.guzev@...>

Next week I'll try to rebuild Ruby with Unicode strings. But it would be

15 messages 2001/06/25
[#16842] Re: national characters is strings — matz@... (Yukihiro Matsumoto) 2001/06/25

Hi,

[#16843] Re: national characters is strings — "Aleksei Guzev" <aleksei.guzev@...> 2001/06/25

That's good enough. But I'm afraid this could ( not would ) cause string

[#16868] Something strange with Ruby's inheritance mechanism — Eric Jacoboni <jaco@...>

As Ruby beginner, i try some "canonical" OO scripts. Doing so, I've

14 messages 2001/06/25
[#16873] RE: Something strange with Ruby's inheritance mechanism — "Aleksei Guzev" <aleksei.guzev@...> 2001/06/26

[#16879] Re: Something strange with Ruby's inheritance mechanism — Mathieu Bouchard <matju@...> 2001/06/26

On Tue, 26 Jun 2001, Aleksei Guzev wrote:

[#16869] Something strange with Ruby's inheritance mechanism — Eric Jacoboni <jaco@...>

As Ruby beginner, i try some "canonical" OO scripts. Doing so, I've

12 messages 2001/06/25

[#16881] — "Aleksei Guzev" <aleksei.guzev@...>

32 messages 2001/06/26
[#16916] Re: Method overloading (option) Was: Re: — "Wayne Blair" <wayne.blair@...> 2001/06/26

[#16920] Re: Method overloading (option) Was: Re: — matz@... (Yukihiro Matsumoto) 2001/06/26

Hi,

[#16888] finalizers, destructors and whatnot — "David Leal" <david@...>

Hi all,

16 messages 2001/06/26

[#17037] keeping an Exception object alive — David Alan Black <dblack@...>

Hello --

19 messages 2001/06/28
[#17055] Re: keeping an Exception object alive — matz@... (Yukihiro Matsumoto) 2001/06/29

Hi,

[#17066] RCR: Exception methods (was: Re: Re: keeping an Exception object alive) — David Alan Black <dblack@...> 2001/06/29

Hello --

[#17076] Re: RCR: Exception methods (was: Re: Re: keeping an Exception object alive) — matz@... (Yukihiro Matsumoto) 2001/06/29

Hi,

[#17079] Re: RCR: Exception methods (was: Re: Re: keeping an Exception object alive) — David Alan Black <dblack@...> 2001/06/29

Hello --

[#17138] Re: RCR: Exception methods (was: Re: Re: keeping an Exception object alive) — matz@... (Yukihiro Matsumoto) 2001/07/02

Hi,

[#17141] Re: RCR: Exception methods (was: Re: Re: keeping an Exception object alive) — David Alan Black <dblack@...> 2001/07/02

Hello --

[#17142] Re: RCR: Exception methods (was: Re: Re: keeping an Exception object alive) — ts <decoux@...> 2001/07/02

>>>>> "D" == David Alan Black <dblack@candle.superlink.net> writes:

[ruby-talk:16819] Re: wrapping structures

From: Martin Chase <stillflame@...>
Date: 2001-06-23 17:38:53 UTC
List: ruby-talk #16819
Guy Decoux wrote:

> why you don't write
>
>   Dictionary LP_dict = dictionary_create(/* ... */);


good point, and at one time i had.  Data_(Get|Wrap)_Struct take pointers to a structure.  the first way i had it was to just use a normal Dictionary variable, and then prepend '&' onto LP_dict when passed to Data_(Get|Wrap)_Struct, but for no reason i could figure out, that only worked with Data_Wrap_Struct - if i do the same with a call to Data_Get_Struct, it failed to compile:
--------------------------
  Dictionary LP_dict;
  int cost;

  Data_Get_Struct(self, Dictionary, &LP_dict);
  cost = dictionary_get_max_cost(LP_dict);
  return INT2NUM(cost);
--------------------------
when compiled produces:
ext/Dictionary.c:59: invalid lvalue in assignment
(59:Data_Get_Struct...)

so i switched to pointers, and made the switch consistently...

however, when i do write the dictionary_create line as you suggested, and use '&' as i mentioned (but still could not change Data_Get_Struct similarly), 'dictionary.get_max_cost' is returning the right value, then '[BUG] segmentation fault'ing immediately afterwards (for the test script, it indicates the error occurred on the same line).  this produces two questions/ideas:
1) why doesn't the Data_Get_Struct/& pattern work the same?  is it because in the sceanario of wrapping the structures, the structure is already populated, but when unwrapping, i use an unallocated structure (doesn't make sense to me, but that's the only difference i can find - maybe the structure i'm wrapping should be dealt with differently, as:
-----------(from the program)-----------
dict = (Dictionary) xalloc(sizeof(struct Dictionary_s));
----------------------------------------
makes Dictionary look like just a pointer to the actual struct)?
2) what happens immediately after get_max_cost is executed that causes it to seg fault?  memory stuff, maybe?

don't worry, these questions are rhetoric for myself, written here only to reasure readers that the help Guy provided is not going to waste (although i don't know how far i'll get on the second question before i'll need help).

thank you very much for your help Guy.  i'm still open to more ideas about this, but have enough to work with for the time being.

Martin Chase <stillflame AT faeriemud DOT org>
"If you think you are too small to make a difference, try sleeping in a closed room with a mosquito..." African Proverb
___________________________________________________
GO.com Mail                                    
Get Your Free, Private E-mail at http://mail.go.com


In This Thread

Prev Next