Thanks for the thumbs up Jim.
My intention is basically to make development easier and give better code
reuse. It is much easier to do
array.resize(&array, 10);
if(array.size!=10)
{
array.destroy(&array);
//do some other clean up and deal with problem as needed
}
Than people writing their own reallocation code every time. It also avoids bugs
where sizes of arrays are not updated and it means that behind the scenes extra
spare memory can be allocated and tracked to avoid extra reallocations.
If drivers need to access the data to read or write fast then they can grab the
pointer and use it raw
double *arrayraw=array.mem;
size_t n = array.size;
for (i=0; i<n; ++I)
//do something with each element
It really comes from the fact that most exit calls come from memory
allocations, so effectively dealing with them is much easier with a more
controlled memory management system. Maybe it also comes from the fact that I
am a C++ person so I get used to the object oriented stuff.
-----Original Message-----
From: "Jim Dishaw" <j...@dishaw.org>
Sent: 22/09/2014 16:32
To: "Phil Rosenberg" <philip_rosenb...@yahoo.com>
Cc: "PLplot development list" <Plplot-devel@lists.sourceforge.net>
Subject: Re: [Plplot-devel] Exit calls and memory management
Unless the memory calls have changed, the "raw pointers" was something I
implemented 5+ years ago when I submitted a patch to transition away from
temporary files.
The design goal I had in mind was speed, to keep the implementation portable,
and to make the memory buffers agnostic to the data. Speed was important to me
because I was using plplot to display data real time. I implemented a simple
"double the memory buffer" when the buffer got full.
I thought about a making the code smarter about memory management, but I
decided that the compiler and OS would suffice and the benefit was (what I
thought) simpler code. I did not want to play whack-a-mole fixing memory
allocation bugs.
That said, tools have gotten better and a fresh look is a good idea.
On Sep 22, 2014, at 10:17 AM, Phil Rosenberg <philip_rosenb...@yahoo.com> wrote:
This one is mostly directed at Alan but probably others will be interested and
may have comments. Git might also be a big help here, but I'm not sure how it
will work so advice from all appreciated.
I have been trying to improve memory management in plplot as part of my attempt
to try to remove exit calls. To do this I am removing raw pointer arrays and
replacing them with a struct which will give us more object oriented access to
memory allocation. I think this will be a generally good thing as the struct
can have function pointers which will allow trivial resizing and adding
elements. It will also be extendible, to allow further functionality similar to
std::vector if we want. Arrays will also know their own size.
However the cost is that arrays in the plstream will all become structs so will
need accessing by somearray.mem[index] or maybe somearray.getMem()[index]
rather than somearray[index]. This has the potential to break some or all the
drivers. Although the fixes might be trivial, I don't have easy access to all
the drivers on my windows machine.
I'm therefore looking for a suggestion of how to proceed. I can transfer stuff
to my Linux machine, but I'm not sure how best to do that with git. I could
create a fork on github so other developers can contribute, but if I create a
public fork then we should merge that into the master branch rather than rebase
it which I think is not compliant with our current workflow.
Any suggestions greatly appreciated.
Phil
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel