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