Previous 199869 Revisions Next

r34447 Sunday 18th January, 2015 at 00:43:59 UTC by Couriersud
Fixed memory allocation in netlist code. This caused a number of memory
leaks to disappear. (nw)
[src/emu/netlist]netlist.mak nl_base.c nl_base.h nl_config.h nl_dice_compat.h nl_factory.c* nl_factory.h* nl_setup.c nl_setup.h plists.h pstate.c pstate.h pstring.c
[src/emu/netlist/analog]nld_ms_direct.h nld_solver.c nld_solver.h
[src/emu/netlist/devices]net_lib.c net_lib.h

trunk/src/emu/netlist/analog/nld_ms_direct.h
r242958r242959
6969   {
7070      //delete[] m_A[k];
7171   }
72   //delete[] m_last_RHS;
72    for (int k = 0; k < N(); k++)
73    {
74        nl_free(m_terms[k]);
75        nl_free(m_row_ops[k]);
76    }
77    nl_free(m_row_ops[N()]);
78    //delete[] m_last_RHS;
7379   //delete[] m_RHS;
74   delete[] m_terms;
75   delete[] m_rails_temp;
80   nl_free_array(m_terms);
81   nl_free_array(m_rails_temp);
7682   //delete[] m_row_ops;
7783
7884}
r242958r242959
452458, m_dim(size)
453459, m_lp_fact(0)
454460{
455   m_terms = new terms_t *[N()];
456   m_rails_temp = new terms_t[N()];
461   m_terms = nl_alloc_array(terms_t *, N());
462   m_rails_temp = nl_alloc_array(terms_t, N());
457463
458464   for (int k = 0; k < N(); k++)
459465   {
460      m_terms[k] = new terms_t;
466      m_terms[k] = nl_alloc(terms_t);
461467      m_row_ops[k] = vector_ops_t::create_ops(k);
462468   }
463469   m_row_ops[N()] = vector_ops_t::create_ops(N());
r242958r242959
469475, m_dim(size)
470476, m_lp_fact(0)
471477{
472    m_terms = new terms_t *[N()];
473    m_rails_temp = new terms_t[N()];
478    m_terms = nl_alloc_array(terms_t *, N());
479    m_rails_temp = nl_alloc_array(terms_t, N());
474480
475481    for (int k = 0; k < N(); k++)
476482    {
477        m_terms[k] = new terms_t;
483        m_terms[k] = nl_alloc(terms_t);
478484        m_row_ops[k] = vector_ops_t::create_ops(k);
479485    }
480486    m_row_ops[N()] = vector_ops_t::create_ops(N());
trunk/src/emu/netlist/analog/nld_solver.c
r242958r242959
4444   switch (size)
4545   {
4646      case 1:
47         return new vector_ops_impl_t<1>();
47         return nl_alloc(vector_ops_impl_t<1>);
4848      case 2:
49         return new vector_ops_impl_t<2>();
49         return nl_alloc(vector_ops_impl_t<2>);
5050      case 3:
51         return new vector_ops_impl_t<3>();
51         return nl_alloc(vector_ops_impl_t<3>);
5252      case 4:
53         return new vector_ops_impl_t<4>();
53         return nl_alloc(vector_ops_impl_t<4>);
5454      case 5:
55         return new vector_ops_impl_t<5>();
55         return nl_alloc(vector_ops_impl_t<5>);
5656      case 6:
57         return new vector_ops_impl_t<6>();
57         return nl_alloc(vector_ops_impl_t<6>);
5858      case 7:
59         return new vector_ops_impl_t<7>();
59         return nl_alloc(vector_ops_impl_t<7>);
6060      case 8:
61         return new vector_ops_impl_t<8>();
61         return nl_alloc(vector_ops_impl_t<8>);
6262      case 9:
63         return new vector_ops_impl_t<9>();
63         return nl_alloc(vector_ops_impl_t<9>);
6464      case 10:
65         return new vector_ops_impl_t<10>();
65         return nl_alloc(vector_ops_impl_t<10>);
6666      case 11:
67         return new vector_ops_impl_t<11>();
67         return nl_alloc(vector_ops_impl_t<11>);
6868      case 12:
69         return new vector_ops_impl_t<12>();
69         return nl_alloc(vector_ops_impl_t<12>);
7070      default:
71         return new vector_ops_impl_t<0>(size);
71         return nl_alloc(vector_ops_impl_t<0>, size);
7272   }
7373}
7474
r242958r242959
9191      m_term[i]->m_Idr1 = &m_Idr[i];
9292      m_other_curanalog[i] = &m_term[i]->m_otherterm->net().as_analog().m_cur_Analog;
9393   }
94
95   m_ops = vector_ops_t::create_ops(m_gt.count());
9694}
9795
9896// ----------------------------------------------------------------------------------------
r242958r242959
112110ATTR_COLD netlist_matrix_solver_t::~netlist_matrix_solver_t()
113111{
114112   for (int i = 0; i < m_inps.count(); i++)
115      delete m_inps[i];
113      global_free(m_inps[i]);
116114}
117115
118116ATTR_COLD void netlist_matrix_solver_t::setup(netlist_analog_net_t::list_t &nets)
r242958r242959
176174
177175                  if (net_proxy_output == NULL)
178176                  {
179                     net_proxy_output = new netlist_analog_output_t();
177                     net_proxy_output = nl_alloc(netlist_analog_output_t);
180178                     net_proxy_output->init_object(*this, this->name() + "." + pstring::sprintf("m%d", m_inps.count()));
181179                     m_inps.add(net_proxy_output);
182180                     net_proxy_output->m_proxied_net = &p->net().as_analog();
r242958r242959
380378   while (e != NULL)
381379   {
382380      netlist_matrix_solver_t * const *en = m_mat_solvers.next(e);
383      delete *e;
381      global_free(*e);
384382      e = en;
385383   }
386384
r242958r242959
435433netlist_matrix_solver_t * NETLIB_NAME(solver)::create_solver(int size, const int gs_threshold, const bool use_specific)
436434{
437435   if (use_specific && m_N == 1)
438      return new netlist_matrix_solver_direct1_t(m_params);
436      return nl_alloc(netlist_matrix_solver_direct1_t, m_params);
439437   else if (use_specific && m_N == 2)
440      return new netlist_matrix_solver_direct2_t(m_params);
438      return nl_alloc(netlist_matrix_solver_direct2_t, m_params);
441439   else
442440   {
441       typedef netlist_matrix_solver_gauss_seidel_t<m_N,_storage_N> solver_N;
443442      if (size >= gs_threshold)
444         return new netlist_matrix_solver_gauss_seidel_t<m_N,_storage_N>(m_params, size);
443         return nl_alloc(solver_N, m_params, size);
445444      else
446         return new netlist_matrix_solver_direct_t<m_N, _storage_N>(m_params, size);
445         return nl_alloc(solver_N, m_params, size);
447446   }
448447}
449448
trunk/src/emu/netlist/analog/nld_solver.h
r242958r242959
155155   NETLIST_PREVENT_COPYING(terms_t)
156156
157157   public:
158   ATTR_COLD terms_t() : m_railstart(0), m_ops(NULL)
158   ATTR_COLD terms_t() : m_railstart(0)
159159   {}
160160
161161   ATTR_COLD void clear()
r242958r242959
175175   ATTR_HOT inline double *go() { return m_go; }
176176   ATTR_HOT inline double *Idr() { return m_Idr; }
177177   ATTR_HOT inline double **other_curanalog() { return m_other_curanalog; }
178   ATTR_HOT vector_ops_t *ops() { return m_ops; }
179178
180179   ATTR_COLD void set_pointers();
181180
r242958r242959
188187   plinearlist_t<double> m_gt;
189188   plinearlist_t<double> m_Idr;
190189   plinearlist_t<double *> m_other_curanalog;
191   vector_ops_t * m_ops;
192190};
193191
194192class netlist_matrix_solver_t : public netlist_device_t
trunk/src/emu/netlist/devices/net_lib.c
r242958r242959
4949
5050#include "net_lib.h"
5151#include "nld_system.h"
52#include "../nl_factory.h"
5253
5354NETLIST_START(diode_models)
5455   NET_MODEL(".model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)")
r242958r242959
6465
6566
6667#define xstr(s) # s
67#define ENTRY1(_nic, _name, _defparam) register_device<_nic>( # _name, xstr(_nic), _defparam );
68#define ENTRY1(_nic, _name, _defparam) factory.register_device<_nic>( # _name, xstr(_nic), _defparam );
6869#define ENTRY(_nic, _name, _defparam) ENTRY1(NETLIB_NAME(_nic), _name, _defparam)
6970
70netlist_factory_t::netlist_factory_t()
71void nl_initialize_factory(netlist_factory_t &factory)
7172{
72}
73
74netlist_factory_t::~netlist_factory_t()
75{
76   for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e))
77   {
78      net_device_t_base_factory *p = *e;
79      delete p;
80   }
81   m_list.clear();
82}
83
84void netlist_factory_t::initialize()
85{
8673   ENTRY(R,                    RES,                    "R")
8774   ENTRY(POT,                  POT,                    "R")
8875   ENTRY(C,                    CAP,                    "C")
r242958r242959
162149   ENTRY(NE555_dip,            NE555_DIP,              "-")
163150}
164151
165netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const
166{
167   for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e))
168   {
169      net_device_t_base_factory *p = *e;
170      if (strcmp(p->classname(), classname) == 0)
171      {
172         netlist_device_t *ret = p->Create();
173         return ret;
174      }
175      p++;
176   }
177   setup.netlist().error("Class %s not found!\n", classname.cstr());
178   return NULL; // appease code analysis
179}
180
181netlist_device_t *netlist_factory_t::new_device_by_name(const pstring &name, netlist_setup_t &setup) const
182{
183   net_device_t_base_factory *f = factory_by_name(name, setup);
184   return f->Create();
185}
186
187net_device_t_base_factory * netlist_factory_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const
188{
189   for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e))
190   {
191      net_device_t_base_factory *p = *e;
192      if (strcmp(p->name(), name) == 0)
193      {
194         return p;
195      }
196      p++;
197   }
198   setup.netlist().error("Class %s not found!\n", name.cstr());
199   return NULL; // appease code analysis
200}
trunk/src/emu/netlist/devices/net_lib.h
r242958r242959
9999NETLIST_EXTERNAL(diode_models);
100100NETLIST_EXTERNAL(bjt_models);
101101
102void nl_initialize_factory(netlist_factory_t &factory);
103
102104#endif
trunk/src/emu/netlist/netlist.mak
r242958r242959
2626   $(NETLISTOBJ)/nl_base.o \
2727   $(NETLISTOBJ)/nl_parser.o \
2828   $(NETLISTOBJ)/nl_setup.o \
29   $(NETLISTOBJ)/nl_factory.o \
2930   $(NETLISTOBJ)/pstring.o \
3031   $(NETLISTOBJ)/pstate.o \
3132   $(NETLISTOBJ)/analog/nld_bjt.o \
trunk/src/emu/netlist/nl_base.c
r242958r242959
152152   {
153153      if (!m_nets[i]->isRailNet())
154154      {
155         delete m_nets[i];
155         global_free(m_nets[i]);
156156      }
157157   }
158158
trunk/src/emu/netlist/nl_base.h
r242958r242959
13701370   }
13711371}
13721372
1373
1374// -----------------------------------------------------------------------------
1375// net_dev class factory
1376// -----------------------------------------------------------------------------
1377
1378class net_device_t_base_factory
1379{
1380   NETLIST_PREVENT_COPYING(net_device_t_base_factory)
1381public:
1382   ATTR_COLD net_device_t_base_factory(const pstring &name, const pstring &classname,
1383         const pstring &def_param)
1384   : m_name(name), m_classname(classname), m_def_param(def_param)
1385   {}
1386
1387   ATTR_COLD virtual ~net_device_t_base_factory() {}
1388
1389   ATTR_COLD virtual netlist_device_t *Create() const = 0;
1390
1391   ATTR_COLD const pstring &name() const { return m_name; }
1392   ATTR_COLD const pstring &classname() const { return m_classname; }
1393   ATTR_COLD const pstring &param_desc() const { return m_def_param; }
1394   ATTR_COLD const nl_util::pstring_list term_param_list();
1395   ATTR_COLD const nl_util::pstring_list def_params();
1396
1397protected:
1398   pstring m_name;                             /* device name */
1399   pstring m_classname;                        /* device class name */
1400   pstring m_def_param;                        /* default parameter */
1401};
1402
1403template <class C>
1404class net_device_t_factory : public net_device_t_base_factory
1405{
1406   NETLIST_PREVENT_COPYING(net_device_t_factory)
1407public:
1408   ATTR_COLD net_device_t_factory(const pstring &name, const pstring &classname,
1409         const pstring &def_param)
1410   : net_device_t_base_factory(name, classname, def_param) { }
1411
1412   ATTR_COLD netlist_device_t *Create() const
1413   {
1414      netlist_device_t *r = new C();
1415      //r->init(setup, name);
1416      return r;
1417   }
1418};
1419
1420class netlist_factory_t
1421{
1422public:
1423   typedef plinearlist_t<net_device_t_base_factory *> list_t;
1424
1425   ATTR_COLD netlist_factory_t();
1426   ATTR_COLD ~netlist_factory_t();
1427
1428   ATTR_COLD void initialize();
1429
1430   template<class _C>
1431   ATTR_COLD void register_device(const pstring &name, const pstring &classname,
1432         const pstring &def_param)
1433   {
1434      m_list.add(new net_device_t_factory< _C >(name, classname, def_param) );
1435   }
1436
1437   ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const;
1438   ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const;
1439   ATTR_COLD net_device_t_base_factory * factory_by_name(const pstring &name, netlist_setup_t &setup) const;
1440
1441   const list_t &list() { return m_list; }
1442
1443private:
1444   list_t m_list;
1445
1446};
1447
1448
14491373#endif /* NLBASE_H_ */
trunk/src/emu/netlist/nl_config.h
r242958r242959
109109// this macro passes an item followed by a string version of itself as two consecutive parameters
110110#define NLNAME(x) x, #x
111111
112//============================================================
113//  Exceptions
114//============================================================
115
112116// emu_fatalerror is a generic fatal exception that provides an error string
113117class nl_fatalerror : public std::exception
114118{
r242958r242959
130134    }
131135};
132136
137//============================================================
138//  Memory allocation
139//============================================================
140
141#define nl_alloc(T, ...)        global_alloc(T(__VA_ARGS__))
142#define nl_alloc_array(T, N)    global_alloc_array(T, N)
143
144#define nl_free(_ptr)           global_free(_ptr)
145#define nl_free_array(_ptr)     global_free_array(_ptr)
146
147
148//============================================================
149//  Asserts
150//============================================================
151
133152#ifdef MAME_DEBUG
134153#define nl_assert(x)               do { if (!(x)) throw nl_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0)
135154#define nl_assert_always(x, msg)   do { if (!(x)) throw nl_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0)
trunk/src/emu/netlist/nl_dice_compat.h
r242958r242959
1313 * -------------------------------------------------------------------- */
1414
1515//#define CHIP(_n, _t) netlist.register_dev(NET_NEW(_t ## _dip), _n);
16#define CHIP(_n, _t) setup.register_dev( new nld_ ## _t ## _dip(), _n);
16#define CHIP(_n, _t) setup.register_dev( nL_alloc(nld_ ## _t ## _dip()), _n);
1717
1818#define CONNECTION( ... ) CONNECTIONY( CONNECTIONX( __VA_ARGS__ ) )
1919#define CONNECTIONY(_a) _a
trunk/src/emu/netlist/nl_factory.c
r0r242959
1// license:GPL-2.0+
2// copyright-holders:Couriersud
3/***************************************************************************
4
5    nl_factory.c
6
7    Discrete netlist implementation.
8
9****************************************************************************
10
11    Couriersud reserves the right to license the code under a less restrictive
12    license going forward.
13
14    Copyright Nicola Salmoria and the MAME team
15    All rights reserved.
16
17    Redistribution and use of this code or any derivative works are permitted
18    provided that the following conditions are met:
19
20    * Redistributions may not be sold, nor may they be used in a commercial
21    product or activity.
22
23    * Redistributions that are modified from the original source must include the
24    complete source code, including the source code for all components used by a
25    binary built from the modified sources. However, as a special exception, the
26    source code distributed need not include anything that is normally distributed
27    (in either source or binary form) with the major components (compiler, kernel,
28    and so on) of the operating system on which the executable runs, unless that
29    component itself accompanies the executable.
30
31    * Redistributions must reproduce the above copyright notice, this list of
32    conditions and the following disclaimer in the documentation and/or other
33    materials provided with the distribution.
34
35    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
36    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
39    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
41    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
42    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
43    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
44    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45    POSSIBILITY OF SUCH DAMAGE.
46
47
48****************************************************************************/
49
50#include "nl_factory.h"
51#include "nl_setup.h"
52
53netlist_factory_t::netlist_factory_t()
54{
55}
56
57netlist_factory_t::~netlist_factory_t()
58{
59   for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e))
60   {
61      net_device_t_base_factory *p = *e;
62      global_free(p);
63   }
64   m_list.clear();
65}
66
67netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const
68{
69   for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e))
70   {
71      net_device_t_base_factory *p = *e;
72      if (strcmp(p->classname(), classname) == 0)
73      {
74         netlist_device_t *ret = p->Create();
75         return ret;
76      }
77      p++;
78   }
79   setup.netlist().error("Class %s not found!\n", classname.cstr());
80   return NULL; // appease code analysis
81}
82
83netlist_device_t *netlist_factory_t::new_device_by_name(const pstring &name, netlist_setup_t &setup) const
84{
85   net_device_t_base_factory *f = factory_by_name(name, setup);
86   return f->Create();
87}
88
89net_device_t_base_factory * netlist_factory_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const
90{
91   for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e))
92   {
93      net_device_t_base_factory *p = *e;
94      if (strcmp(p->name(), name) == 0)
95      {
96         return p;
97      }
98      p++;
99   }
100   setup.netlist().error("Class %s not found!\n", name.cstr());
101   return NULL; // appease code analysis
102}
trunk/src/emu/netlist/nl_factory.h
r0r242959
1// license:GPL-2.0+
2// copyright-holders:Couriersud
3/*
4 * nl_factory.h
5 *
6 *
7 */
8
9#ifndef NLFACTORY_H_
10#define NLFACTORY_H_
11
12#include "nl_config.h"
13#include "plists.h"
14#include "nl_base.h"
15#if 0
16#include "nl_time.h"
17#include "nl_util.h"
18#include "pstate.h"
19#endif
20#include "pstring.h"
21
22// -----------------------------------------------------------------------------
23// net_dev class factory
24// -----------------------------------------------------------------------------
25
26class net_device_t_base_factory
27{
28   NETLIST_PREVENT_COPYING(net_device_t_base_factory)
29public:
30   ATTR_COLD net_device_t_base_factory(const pstring &name, const pstring &classname,
31         const pstring &def_param)
32   : m_name(name), m_classname(classname), m_def_param(def_param)
33   {}
34
35   ATTR_COLD virtual ~net_device_t_base_factory() {}
36
37   ATTR_COLD virtual netlist_device_t *Create() const = 0;
38
39   ATTR_COLD const pstring &name() const { return m_name; }
40   ATTR_COLD const pstring &classname() const { return m_classname; }
41   ATTR_COLD const pstring &param_desc() const { return m_def_param; }
42   ATTR_COLD const nl_util::pstring_list term_param_list();
43   ATTR_COLD const nl_util::pstring_list def_params();
44
45protected:
46   pstring m_name;                             /* device name */
47   pstring m_classname;                        /* device class name */
48   pstring m_def_param;                        /* default parameter */
49};
50
51template <class C>
52class net_device_t_factory : public net_device_t_base_factory
53{
54   NETLIST_PREVENT_COPYING(net_device_t_factory)
55public:
56   ATTR_COLD net_device_t_factory(const pstring &name, const pstring &classname,
57         const pstring &def_param)
58   : net_device_t_base_factory(name, classname, def_param) { }
59
60   ATTR_COLD netlist_device_t *Create() const
61   {
62      netlist_device_t *r = nl_alloc(C);
63      //r->init(setup, name);
64      return r;
65   }
66};
67
68class netlist_factory_t
69{
70public:
71   typedef plinearlist_t<net_device_t_base_factory *> list_t;
72
73   ATTR_COLD netlist_factory_t();
74   ATTR_COLD ~netlist_factory_t();
75
76   template<class _C>
77   ATTR_COLD void register_device(const pstring &name, const pstring &classname,
78         const pstring &def_param)
79   {
80      m_list.add(nl_alloc(net_device_t_factory< _C >, name, classname, def_param));
81   }
82
83   ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const;
84   ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const;
85   ATTR_COLD net_device_t_base_factory * factory_by_name(const pstring &name, netlist_setup_t &setup) const;
86
87   const list_t &list() { return m_list; }
88
89private:
90   list_t m_list;
91
92};
93
94
95#endif /* NLFACTORY_H_ */
trunk/src/emu/netlist/nl_setup.c
r242958r242959
4141
4242void netlist_setup_t::init()
4343{
44   m_factory.initialize();
44   nl_initialize_factory(factory());
4545   NETLIST_NAME(base)(*this);
4646}
4747
r242958r242959
390390   if (proxy == NULL)
391391   {
392392      // create a new one ...
393      proxy = new nld_d_to_a_proxy(out);
393      proxy = nl_alloc(nld_d_to_a_proxy ,out);
394394      pstring x = pstring::sprintf("proxy_da_%s_%d", out.name().cstr(), m_proxy_cnt);
395395      m_proxy_cnt++;
396396
r242958r242959
419419{
420420   if (out.isFamily(netlist_terminal_t::ANALOG) && in.isFamily(netlist_terminal_t::LOGIC))
421421   {
422      nld_a_to_d_proxy *proxy = new nld_a_to_d_proxy(in);
422      nld_a_to_d_proxy *proxy = nl_alloc(nld_a_to_d_proxy, in);
423423      pstring x = pstring::sprintf("proxy_ad_%s_%d", in.name().cstr(), m_proxy_cnt);
424424      m_proxy_cnt++;
425425
r242958r242959
455455   else if (inp.isFamily(netlist_terminal_t::LOGIC))
456456   {
457457      NL_VERBOSE_OUT(("connect_terminal_input: connecting proxy\n"));
458      nld_a_to_d_proxy *proxy = new nld_a_to_d_proxy(inp);
458      nld_a_to_d_proxy *proxy = nl_alloc(nld_a_to_d_proxy, inp);
459459      pstring x = pstring::sprintf("proxy_ad_%s_%d", inp.name().cstr(), m_proxy_cnt);
460460      m_proxy_cnt++;
461461
r242958r242959
523523   else
524524   {
525525      NL_VERBOSE_OUT(("adding net ...\n"));
526      netlist_analog_net_t *anet =  new netlist_analog_net_t();
526      netlist_analog_net_t *anet =  nl_alloc(netlist_analog_net_t);
527527      t1.set_net(*anet);
528528      //m_netlist.solver()->m_nets.add(anet);
529529      // FIXME: Nets should have a unique name
trunk/src/emu/netlist/nl_setup.h
r242958r242959
1111#define NLSETUP_H_
1212
1313#include "nl_base.h"
14#include "nl_factory.h"
1415
1516//============================================================
1617//  MACROS / inline netlist definitions
trunk/src/emu/netlist/plists.h
r242958r242959
2828      if (m_num_elements == 0)
2929         m_list = NULL;
3030      else
31         m_list = new _ListClass[m_num_elements];
31         m_list = nl_alloc_array(_ListClass, m_num_elements);
3232      m_count = 0;
3333   }
3434
r242958r242959
3838      if (m_num_elements == 0)
3939         m_list = NULL;
4040      else
41         m_list = new _ListClass[m_num_elements];
41         m_list = nl_alloc_array(_ListClass, m_num_elements);
4242      m_count = 0;
4343      for (int i=0; i<rhs.count(); i++)
4444      {
r242958r242959
6060   ATTR_COLD ~plinearlist_t()
6161   {
6262      if (m_list != NULL)
63         delete[] m_list;
63          nl_free_array(m_list);
6464      m_list = NULL;
6565   }
6666
r242958r242959
157157   {
158158      for (_ListClass *i = m_list; i < m_list + m_count; i++)
159159      {
160         delete *i;
160         nl_free(*i);
161161      }
162162      clear();
163163   }
164164
165165private:
166   ATTR_HOT inline void resize(const int new_size)
166   ATTR_COLD void resize(const int new_size)
167167   {
168168      int cnt = count();
169169      if (new_size > 0)
170170      {
171         _ListClass *m_new = new _ListClass[new_size];
171         _ListClass *m_new = nl_alloc_array(_ListClass, new_size);
172172         _ListClass *pd = m_new;
173173
174174         if (cnt > new_size)
r242958r242959
176176         for (_ListClass *ps = m_list; ps < m_list + cnt; ps++, pd++)
177177            *pd = *ps;
178178         if (m_list != NULL)
179            delete[] m_list;
179            nl_free_array(m_list);
180180         m_list = m_new;
181181         m_count = cnt;
182182      }
183183      else
184184      {
185185         if (m_list != NULL)
186            delete[] m_list;
186             nl_free_array(m_list);
187187         m_list = NULL;
188188         m_count = 0;
189189      }
trunk/src/emu/netlist/pstate.c
r242958r242959
2727   };
2828
2929   NL_VERBOSE_OUT(("SAVE: <%s> %s(%d) %p\n", fullname.cstr(), ts[dt].cstr(), size, ptr));
30   pstate_entry_t *p = new pstate_entry_t(stname, dt, owner, size, count, ptr, is_ptr);
30   pstate_entry_t *p = nl_alloc(pstate_entry_t, stname, dt, owner, size, count, ptr, is_ptr);
3131   m_save.add(p);
3232}
3333
r242958r242959
6060      if (m_save[i]->m_dt == DT_CUSTOM)
6161         m_save[i]->m_callback->on_post_load();
6262}
63
64template<> ATTR_COLD void pstate_manager_t::save_item(pstate_callback_t &state, const void *owner, const pstring &stname)
65{
66    //save_state_ptr(stname, DT_CUSTOM, 0, 1, &state);
67    pstate_entry_t *p = nl_alloc(pstate_entry_t, stname, owner, &state);
68    m_save.add(p);
69    state.register_state(*this, stname);
70}
trunk/src/emu/netlist/pstate.h
r242958r242959
145145   pstate_entry_t::list_t m_save;
146146};
147147
148template<> ATTR_COLD inline void pstate_manager_t::save_item(pstate_callback_t &state, const void *owner, const pstring &stname)
149{
150   //save_state_ptr(stname, DT_CUSTOM, 0, 1, &state);
151   pstate_entry_t *p = new pstate_entry_t(stname, owner, &state);
152   m_save.add(p);
153   state.register_state(*this, stname);
154}
148template<> ATTR_COLD void pstate_manager_t::save_item(pstate_callback_t &state, const void *owner, const pstring &stname);
155149
156150template<> ATTR_COLD inline void pstate_manager_t::save_item(netlist_time &nlt, const void *owner, const pstring &stname)
157151{
trunk/src/emu/netlist/pstring.c
r242958r242959
1414//pstring::str_t *pstring::m_zero = new(pstring::m_pool, 0) pstring::str_t(0);
1515
1616pblockpool pstring::m_pool;
17
1817pstring::str_t pstring::m_zero;
1918
2019/*


Previous 199869 Revisions Next


© 1997-2024 The MAME Team