Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    GeDynamicArray access violation

    SDK Help
    0
    5
    414
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 17/12/2007 at 01:24, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   9.5+ 
      Platform:   Windows  ; Mac  ;  Mac OSX  ; 
      Language(s) :

      ---------
      Greetings,

      I have a rather strange problem. I'm using GeDynamicArray (GeDynamicArray<Real> data;) in some class (layer_graph_data), and it seems to crash when c4d wants to free it. The funny thing is, it crashes only when using layer_graph_data as a pointer, eg. layer_graph_data* a=new layer_graph_data(); delete(a); and only if it's created in another class (layer_data in my example, which is allocated in the main ObjectData class), but works quite fine when allocated in the main class. And it works just fine with layer_graph_data a; in either of those two examples.

      Debugger says the exception happens in
      GeFree(ptr); of template<class TYPE> void GeDynamicArray<TYPE>::Free(void) in ge_dynamicarray.h.

      Any ideas why this might happen?

      Thanks,
      Miha

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 17/12/2007 at 01:52, xxxxxxxx wrote:

        No clear idea what might cause the crash without seeing your source code. Just remember to use Cinema's own allocation functions (bNew, bDelete, gNew, gDelete etc.) whenever possible.

        cheers,
        Matthias

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 17/12/2007 at 02:21, xxxxxxxx wrote:

          _
          > #pragma once
          >
          > #include "c4d.h"
          > #include "ge_dynamicarray.h"
          >
          >
          > class layer_graph_data {
          > private:
          >      GeDynamicArray<Real> data;
          >      LONG size;
          >
          >      LONG channel;
          >
          >
          >      LONG delay;
          >
          > public:
          >      layer_graph_data(void);
          >      layer_graph_data(LONG _channel);
          >      ~layer_graph_data(void);
          >
          > };
          >
          > layer_graph_data::layer_graph_data(void) {
          >      size=0;
          >      delay=0;
          >      channel=0;
          > }
          >
          > layer_graph_data::layer_graph_data(LONG _channel) {
          >      size=0;
          >      channel=_channel;
          >      delay=0;
          > }
          >
          > layer_graph_data::~layer_graph_data(void) {
          >
          > }
          >
          >
          >
          > #include "c4d.h"
          > #include "layer_graph_data.h"
          >
          > class layer_data
          > {
          >
          > private:
          >      Real max;
          >      String name;
          >      LONG channel;
          >      Vector namebox;
          >
          >      Real exp;
          >
          >      layer_graph_data* graph_data;
          >
          > public:
          >      Vector corner_LT, corner_RB, off1, off2;
          >      Bool selected;
          >
          > public:
          >
          > public:
          >      layer_data(void);
          >      layer_data(Vector _corner_LT, Vector _corner_RB);
          >      ~layer_data(void);
          > };
          >
          >
          >
          > #include "Layer.h"
          >
          > layer_data::layer_data(void)
          > {
          >      graph_data=gNew layer_graph_data();
          >
          >      graph_data->setChannel(channel);
          >      exp=2;
          > }
          >
          > layer_data::~layer_data(void)
          > {
          >      gDelete(graph_data);
          > }
          >
          > layer_data::layer_data(Vector _corner_LT, Vector _corner_RB)
          > {
          >      graph_data=gNew layer_graph_data();
          >
          >      corner_LT = _corner_LT;
          >      corner_RB = _corner_RB;
          >
          >      graph_data->setChannel(channel);
          >      exp=2;
          > }
          > _

          in the main plugin class layer_data is used

          > _
          > private:
          > GeDynamicArray <layer_data> layer_store;
          >
          > Bool Init(GeListNode *node) {
          > layer_store.Push(layer_data(Vector(0.1,0.1,0),Vector(0.2,0.3,0)));
          >      layer_store.Push(layer_data(Vector(0.3,0.4,0),Vector(0.4,0.6,0)));
          >      layer_store.Push(layer_data(Vector(0.2,0.2,0),Vector(0.3,0.8,0)));
          > }
          > _

          hope this makes sense. 🙂

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 17/12/2007 at 02:37, xxxxxxxx wrote:

            Ok now that is weird. When i changed GeDynamicArray_<_layer_data_>_ layer_store; to GeDynamicA_<_layer_data*_>_ta*> layer_store; and used gNew and gDelete on its elements it resolved itself...

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 17/12/2007 at 05:50, xxxxxxxx wrote:

              I also encountered crashes with GeDynamicArray some time ago, however only in a multiprocessor context and when trying to change the stacked array during MP processing (for example during rendering).

              1 Reply Last reply Reply Quote 0
              • First post
                Last post