Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum wrote:
>object_index_no_free*() will add a reference for the item on the
>stack, so you need to free the svalue afterwards, which is
>conveniently done by pop_stack().  There is no difference between your
>two snippets; object_index_no_free*() adds a ref, so you need to
>subtract it when you're done.

So how do I do an efficient:

   class A {
     array b;
   };

   A c=A();
...
  then from with the CMOD:

   c->b+=({12});

I would like the += code to destructively expand array b, which would be
possible if it had only one reference.
But object_index_no_free adds a reference, you say.  So how do I solve
this?

I use this:
    push_int(12);
    f_aggregate(1);
    Pike_sp++;
    object_index_no_free2(Pike_sp-1, portal,0, MK_STRING_SVALUE("_datarows"));
    stack_swap();
    f_add(2);
    object_set_index2(portal,0, MK_STRING_SVALUE("_datarows"), Pike_sp-1);
    Pike_sp--;

I realise that I need to run pop_stack() at the end instead, but that
still leaves me puzzled about the efficient append.
-- 
Sincerely,
           Stephen R. van den Berg.

"Well, if we're going to make a party of it, let's nibble Nobby's nuts!"
  • Acc... Stephen R. van den Berg
    • ... Stephen R. van den Berg
    • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
      • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
        • ... Stephen R. van den Berg
          • ... Stephen R. van den Berg
            • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
              • ... Stephen R. van den Berg
                • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
                • ... Stephen R. van den Berg
                • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
                • ... Henrik Grubbström (Lysator) @ Pike (-) developers forum
                • ... Mirar @ Pike developers forum
                • ... Stephen R. van den Berg
                • ... Mirar @ Pike developers forum
                • ... Stephen R. van den Berg
                • ... Mirar @ Pike developers forum
                • ... Stephen R. van den Berg

Reply via email to