mirror of
https://github.com/holub/mame
synced 2025-07-05 18:08:04 +03:00
Netlist: Documented 7430 & 7486
This commit is contained in:
parent
82f5aa9a0c
commit
a717c13507
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -2131,6 +2131,9 @@ src/emu/netlist/devices/nld_7410.h svneol=native#text/plain
|
|||||||
src/emu/netlist/devices/nld_7420.h svneol=native#text/plain
|
src/emu/netlist/devices/nld_7420.h svneol=native#text/plain
|
||||||
src/emu/netlist/devices/nld_7425.h svneol=native#text/plain
|
src/emu/netlist/devices/nld_7425.h svneol=native#text/plain
|
||||||
src/emu/netlist/devices/nld_7427.h svneol=native#text/plain
|
src/emu/netlist/devices/nld_7427.h svneol=native#text/plain
|
||||||
|
src/emu/netlist/devices/nld_7430.h svneol=native#text/plain
|
||||||
|
src/emu/netlist/devices/nld_7486.c svneol=native#text/plain
|
||||||
|
src/emu/netlist/devices/nld_7486.h svneol=native#text/plain
|
||||||
src/emu/netlist/devices/nld_signal.h svneol=native#text/plain
|
src/emu/netlist/devices/nld_signal.h svneol=native#text/plain
|
||||||
src/emu/netlist/devices/nld_system.c svneol=native#text/plain
|
src/emu/netlist/devices/nld_system.c svneol=native#text/plain
|
||||||
src/emu/netlist/devices/nld_system.h svneol=native#text/plain
|
src/emu/netlist/devices/nld_system.h svneol=native#text/plain
|
||||||
|
@ -280,20 +280,6 @@ NETLIB_UPDATE(nic7404)
|
|||||||
OUTLOGIC(m_Q, t, delay[t]);
|
OUTLOGIC(m_Q, t, delay[t]);
|
||||||
}
|
}
|
||||||
|
|
||||||
NETLIB_START(nic7486)
|
|
||||||
{
|
|
||||||
register_input("I1", m_I0);
|
|
||||||
register_input("I2", m_I1);
|
|
||||||
register_output("Q", m_Q);
|
|
||||||
}
|
|
||||||
|
|
||||||
NETLIB_UPDATE(nic7486)
|
|
||||||
{
|
|
||||||
static const netlist_time delay[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) };
|
|
||||||
UINT8 t = INPLOGIC(m_I0) ^ INPLOGIC(m_I1);
|
|
||||||
OUTLOGIC(m_Q, t, delay[t]);
|
|
||||||
}
|
|
||||||
|
|
||||||
NETLIB_START(nic7448)
|
NETLIB_START(nic7448)
|
||||||
{
|
{
|
||||||
register_sub(sub, "sub");
|
register_sub(sub, "sub");
|
||||||
|
@ -60,6 +60,8 @@
|
|||||||
#include "nld_7420.h"
|
#include "nld_7420.h"
|
||||||
#include "nld_7425.h"
|
#include "nld_7425.h"
|
||||||
#include "nld_7427.h"
|
#include "nld_7427.h"
|
||||||
|
#include "nld_7430.h"
|
||||||
|
#include "nld_7486.h"
|
||||||
|
|
||||||
// this is a bad hack
|
// this is a bad hack
|
||||||
#define USE_OLD7493 (0)
|
#define USE_OLD7493 (0)
|
||||||
@ -97,25 +99,10 @@
|
|||||||
// TTL Logic chips
|
// TTL Logic chips
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define TTL_7404_INVERT(_name, _I1) \
|
#define TTL_7404_INVERT(_name, _I1) \
|
||||||
NET_REGISTER_DEV(nic7404, _name) \
|
NET_REGISTER_DEV(nic7404, _name) \
|
||||||
NET_CONNECT(_name, I1, _I1)
|
NET_CONNECT(_name, I1, _I1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define TTL_7430_NAND(_name, _I1, _I2, _I3, _I4, _I5, _I6, _I7, _I8) \
|
|
||||||
NET_REGISTER_DEV(nic7430, _name) \
|
|
||||||
NET_CONNECT(_name, A, _I1) \
|
|
||||||
NET_CONNECT(_name, B, _I2) \
|
|
||||||
NET_CONNECT(_name, C, _I3) \
|
|
||||||
NET_CONNECT(_name, D, _I4) \
|
|
||||||
NET_CONNECT(_name, E, _I5) \
|
|
||||||
NET_CONNECT(_name, F, _I6) \
|
|
||||||
NET_CONNECT(_name, G, _I7) \
|
|
||||||
NET_CONNECT(_name, H, _I8)
|
|
||||||
|
|
||||||
#define TTL_7450_ANDORINVERT(_name, _I1, _I2, _I3, _I4) \
|
#define TTL_7450_ANDORINVERT(_name, _I1, _I2, _I3, _I4) \
|
||||||
NET_REGISTER_DEV(nic7450, _name) \
|
NET_REGISTER_DEV(nic7450, _name) \
|
||||||
NET_CONNECT(_name, I1, _I1) \
|
NET_CONNECT(_name, I1, _I1) \
|
||||||
@ -123,11 +110,6 @@
|
|||||||
NET_CONNECT(_name, I3, _I3) \
|
NET_CONNECT(_name, I3, _I3) \
|
||||||
NET_CONNECT(_name, I4, _I4)
|
NET_CONNECT(_name, I4, _I4)
|
||||||
|
|
||||||
#define TTL_7486_XOR(_name, _I1, _I2) \
|
|
||||||
NET_REGISTER_DEV(nic7486, _name) \
|
|
||||||
NET_CONNECT(_name, I1, _I1) \
|
|
||||||
NET_CONNECT(_name, I2, _I2)
|
|
||||||
|
|
||||||
#define TTL_7448(_name, _A0, _A1, _A2, _A3, _LTQ, _BIQ, _RBIQ) \
|
#define TTL_7448(_name, _A0, _A1, _A2, _A3, _LTQ, _BIQ, _RBIQ) \
|
||||||
NET_REGISTER_DEV(nic7448, _name) \
|
NET_REGISTER_DEV(nic7448, _name) \
|
||||||
NET_CONNECT(_name, A0, _A0) \
|
NET_CONNECT(_name, A0, _A0) \
|
||||||
@ -297,7 +279,7 @@ NETLIB_DEVICE_WITH_PARAMS(nicNE555N_MSTABLE,
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
NETLIB_SIGNAL(nic7430, 8, 0, 0);
|
|
||||||
|
|
||||||
NETLIB_DEVICE(nic7404,
|
NETLIB_DEVICE(nic7404,
|
||||||
netlist_ttl_input_t m_I;
|
netlist_ttl_input_t m_I;
|
||||||
@ -330,12 +312,6 @@ NETLIB_DEVICE(nic7474,
|
|||||||
netlist_ttl_input_t m_preQ;
|
netlist_ttl_input_t m_preQ;
|
||||||
);
|
);
|
||||||
|
|
||||||
NETLIB_DEVICE(nic7486,
|
|
||||||
netlist_ttl_input_t m_I0;
|
|
||||||
netlist_ttl_input_t m_I1;
|
|
||||||
netlist_ttl_output_t m_Q;
|
|
||||||
);
|
|
||||||
|
|
||||||
/* 74107 does latch data during high !
|
/* 74107 does latch data during high !
|
||||||
* For modelling purposes, we assume 74107 and 74107A are the same
|
* For modelling purposes, we assume 74107 and 74107A are the same
|
||||||
*/
|
*/
|
||||||
|
@ -29,11 +29,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nld_signal.h"
|
|
||||||
|
|
||||||
#ifndef NLD_7400_H_
|
#ifndef NLD_7400_H_
|
||||||
#define NLD_7400_H_
|
#define NLD_7400_H_
|
||||||
|
|
||||||
|
#include "nld_signal.h"
|
||||||
|
|
||||||
#define TTL_7400_NAND(_name, _A, _B) \
|
#define TTL_7400_NAND(_name, _A, _B) \
|
||||||
NET_REGISTER_DEV(7400, _name) \
|
NET_REGISTER_DEV(7400, _name) \
|
||||||
NET_CONNECT(_name, A, _A) \
|
NET_CONNECT(_name, A, _A) \
|
||||||
|
@ -29,12 +29,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "nld_signal.h"
|
|
||||||
|
|
||||||
#ifndef NLD_7402_H_
|
#ifndef NLD_7402_H_
|
||||||
#define NLD_7402_H_
|
#define NLD_7402_H_
|
||||||
|
|
||||||
|
#include "nld_signal.h"
|
||||||
|
|
||||||
#define TTL_7402_NOR(_name, _I1, _I2) \
|
#define TTL_7402_NOR(_name, _I1, _I2) \
|
||||||
NET_REGISTER_DEV(7402, _name) \
|
NET_REGISTER_DEV(7402, _name) \
|
||||||
NET_CONNECT(_name, A, _I1) \
|
NET_CONNECT(_name, A, _I1) \
|
||||||
|
@ -29,12 +29,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "nld_signal.h"
|
|
||||||
|
|
||||||
#ifndef NLD_7410_H_
|
#ifndef NLD_7410_H_
|
||||||
#define NLD_7410_H_
|
#define NLD_7410_H_
|
||||||
|
|
||||||
|
#include "nld_signal.h"
|
||||||
|
|
||||||
#define TTL_7410_NAND(_name, _I1, _I2, _I3) \
|
#define TTL_7410_NAND(_name, _I1, _I2, _I3) \
|
||||||
NET_REGISTER_DEV(7410, _name) \
|
NET_REGISTER_DEV(7410, _name) \
|
||||||
NET_CONNECT(_name, A, _I1) \
|
NET_CONNECT(_name, A, _I1) \
|
||||||
|
@ -30,12 +30,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "nld_signal.h"
|
|
||||||
|
|
||||||
#ifndef NLD_7420_H_
|
#ifndef NLD_7420_H_
|
||||||
#define NLD_7420_H_
|
#define NLD_7420_H_
|
||||||
|
|
||||||
|
#include "nld_signal.h"
|
||||||
|
|
||||||
#define TTL_7420_NAND(_name, _I1, _I2, _I3, _I4) \
|
#define TTL_7420_NAND(_name, _I1, _I2, _I3, _I4) \
|
||||||
NET_REGISTER_DEV(7420, _name) \
|
NET_REGISTER_DEV(7420, _name) \
|
||||||
NET_CONNECT(_name, A, _I1) \
|
NET_CONNECT(_name, A, _I1) \
|
||||||
|
@ -33,12 +33,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "nld_signal.h"
|
|
||||||
|
|
||||||
#ifndef NLD_7425_H_
|
#ifndef NLD_7425_H_
|
||||||
#define NLD_7425_H_
|
#define NLD_7425_H_
|
||||||
|
|
||||||
|
#include "nld_signal.h"
|
||||||
|
|
||||||
#define TTL_7425_NOR(_name, _I1, _I2, _I3, _I4) \
|
#define TTL_7425_NOR(_name, _I1, _I2, _I3, _I4) \
|
||||||
NET_REGISTER_DEV(7425, _name) \
|
NET_REGISTER_DEV(7425, _name) \
|
||||||
NET_CONNECT(_name, A, _I1) \
|
NET_CONNECT(_name, A, _I1) \
|
||||||
|
@ -29,12 +29,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "nld_signal.h"
|
|
||||||
|
|
||||||
#ifndef NLD_7427_H_
|
#ifndef NLD_7427_H_
|
||||||
#define NLD_7427_H_
|
#define NLD_7427_H_
|
||||||
|
|
||||||
|
#include "nld_signal.h"
|
||||||
|
|
||||||
#define TTL_7427_NOR(_name, _I1, _I2, _I3) \
|
#define TTL_7427_NOR(_name, _I1, _I2, _I3) \
|
||||||
NET_REGISTER_DEV(7427, _name) \
|
NET_REGISTER_DEV(7427, _name) \
|
||||||
NET_CONNECT(_name, A, _I1) \
|
NET_CONNECT(_name, A, _I1) \
|
||||||
|
56
src/emu/netlist/devices/nld_7430.h
Normal file
56
src/emu/netlist/devices/nld_7430.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// license:GPL-2.0+
|
||||||
|
// copyright-holders:Couriersud
|
||||||
|
/*
|
||||||
|
* nld_7430.h
|
||||||
|
*
|
||||||
|
* DM7430: 8-Input NAND Gate
|
||||||
|
*
|
||||||
|
* +--------------+
|
||||||
|
* A |1 ++ 14| VCC
|
||||||
|
* B |2 13| NC
|
||||||
|
* C |3 12| H
|
||||||
|
* D |4 7430 11| G
|
||||||
|
* E |5 10| NC
|
||||||
|
* F |6 9| NC
|
||||||
|
* GND |7 8| Y
|
||||||
|
* +--------------+
|
||||||
|
* ________
|
||||||
|
* Y = ABCDEFGH
|
||||||
|
* +---+---+---+---+---+---+---+---++---+
|
||||||
|
* | A | B | C | D | E | F | G | H || Y |
|
||||||
|
* +===+===+===+===+===+===+===+===++===+
|
||||||
|
* | X | X | X | X | X | X | X | 0 || 1 |
|
||||||
|
* | X | X | X | X | X | X | 0 | X || 1 |
|
||||||
|
* | X | X | X | X | X | 0 | X | X || 1 |
|
||||||
|
* | X | X | X | X | 0 | X | X | X || 1 |
|
||||||
|
* | X | X | X | 0 | X | X | X | X || 1 |
|
||||||
|
* | X | X | 0 | X | X | X | X | X || 1 |
|
||||||
|
* | X | 0 | X | X | X | X | X | X || 1 |
|
||||||
|
* | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 || 0 |
|
||||||
|
* +---+---+---+---+---+---+---+---++---+
|
||||||
|
*
|
||||||
|
* Naming conventions follow National Semiconductor datasheet
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NLD_7430_H_
|
||||||
|
#define NLD_7430_H_
|
||||||
|
|
||||||
|
#include "nld_signal.h"
|
||||||
|
|
||||||
|
#define TTL_7430_NAND(_name, _I1, _I2, _I3, _I4, _I5, _I6, _I7, _I8) \
|
||||||
|
NET_REGISTER_DEV(nic7430, _name) \
|
||||||
|
NET_CONNECT(_name, A, _I1) \
|
||||||
|
NET_CONNECT(_name, B, _I2) \
|
||||||
|
NET_CONNECT(_name, C, _I3) \
|
||||||
|
NET_CONNECT(_name, D, _I4) \
|
||||||
|
NET_CONNECT(_name, E, _I5) \
|
||||||
|
NET_CONNECT(_name, F, _I6) \
|
||||||
|
NET_CONNECT(_name, G, _I7) \
|
||||||
|
NET_CONNECT(_name, H, _I8)
|
||||||
|
|
||||||
|
|
||||||
|
NETLIB_SIGNAL(nic7430, 8, 0, 0);
|
||||||
|
|
||||||
|
#endif /* NLD_7430_H_ */
|
21
src/emu/netlist/devices/nld_7486.c
Normal file
21
src/emu/netlist/devices/nld_7486.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* nld_7486.c
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nld_7486.h"
|
||||||
|
|
||||||
|
NETLIB_START(nic7486)
|
||||||
|
{
|
||||||
|
register_input("A", m_A);
|
||||||
|
register_input("B", m_B);
|
||||||
|
register_output("Q", m_Q);
|
||||||
|
}
|
||||||
|
|
||||||
|
NETLIB_UPDATE(nic7486)
|
||||||
|
{
|
||||||
|
static const netlist_time delay[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) };
|
||||||
|
UINT8 t = INPLOGIC(m_A) ^ INPLOGIC(m_B);
|
||||||
|
OUTLOGIC(m_Q, t, delay[t]);
|
||||||
|
}
|
||||||
|
|
47
src/emu/netlist/devices/nld_7486.h
Normal file
47
src/emu/netlist/devices/nld_7486.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// license:GPL-2.0+
|
||||||
|
// copyright-holders:Couriersud
|
||||||
|
/*
|
||||||
|
* nld_7486.h
|
||||||
|
*
|
||||||
|
* DM7486: Quad 2-Input NAND Gates
|
||||||
|
*
|
||||||
|
* +--------------+
|
||||||
|
* A1 |1 ++ 14| VCC
|
||||||
|
* B1 |2 13| B4
|
||||||
|
* Y1 |3 12| A4
|
||||||
|
* A2 |4 7486 11| Y4
|
||||||
|
* B2 |5 10| B3
|
||||||
|
* Y2 |6 9| A3
|
||||||
|
* GND |7 8| Y3
|
||||||
|
* +--------------+
|
||||||
|
*
|
||||||
|
* Y = A+B
|
||||||
|
* +---+---++---+
|
||||||
|
* | A | B || Y |
|
||||||
|
* +===+===++===+
|
||||||
|
* | 0 | 0 || 0 |
|
||||||
|
* | 0 | 1 || 1 |
|
||||||
|
* | 1 | 0 || 1 |
|
||||||
|
* | 1 | 1 || 0 |
|
||||||
|
* +---+---++---+
|
||||||
|
*
|
||||||
|
* Naming conventions follow National Semiconductor datasheet
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NLD_7486_H_
|
||||||
|
#define NLD_7486_H_
|
||||||
|
|
||||||
|
#include "nld_signal.h"
|
||||||
|
|
||||||
|
#define TTL_7486_XOR(_name, _A, _B) \
|
||||||
|
NET_REGISTER_DEV(nic7486, _name) \
|
||||||
|
NET_CONNECT(_name, A, _A) \
|
||||||
|
NET_CONNECT(_name, B, _B)
|
||||||
|
|
||||||
|
NETLIB_DEVICE(nic7486,
|
||||||
|
netlist_ttl_input_t m_A;
|
||||||
|
netlist_ttl_input_t m_B;
|
||||||
|
netlist_ttl_output_t m_Q;
|
||||||
|
);
|
||||||
|
#endif /* NLD_7486_H_ */
|
@ -24,4 +24,5 @@ NETLISTOBJS+= \
|
|||||||
$(NETLISTOBJ)/nl_parser.o \
|
$(NETLISTOBJ)/nl_parser.o \
|
||||||
$(NETLISTOBJ)/devices/nld_system.o \
|
$(NETLISTOBJ)/devices/nld_system.o \
|
||||||
$(NETLISTOBJ)/devices/net_lib.o \
|
$(NETLISTOBJ)/devices/net_lib.o \
|
||||||
|
$(NETLISTOBJ)/devices/nld_7486.o \
|
||||||
|
|
||||||
|
@ -107,112 +107,109 @@ pstring pstring::sprintf(const char *format, ...)
|
|||||||
|
|
||||||
char *pstring::alloc_str(int n)
|
char *pstring::alloc_str(int n)
|
||||||
{
|
{
|
||||||
#if (IMMEDIATE_MODE)
|
if (IMMEDIATE_MODE)
|
||||||
return (char *) malloc(n);
|
return (char *) malloc(n);
|
||||||
#else
|
else
|
||||||
#if (DEBUG_MODE)
|
|
||||||
int min_alloc = MAX(0, n+sizeof(memblock));
|
|
||||||
#else
|
|
||||||
int min_alloc = MAX(8192, n+sizeof(memblock));
|
|
||||||
#endif
|
|
||||||
char *ret = NULL;
|
|
||||||
|
|
||||||
//std::printf("m_first %p\n", m_first);
|
|
||||||
for (memblock *p = m_first; p != NULL && ret == NULL; p = p->next)
|
|
||||||
{
|
{
|
||||||
if (p->remaining > n)
|
int min_alloc = MAX((DEBUG_MODE) ? 0 : 8192, n+sizeof(memblock));
|
||||||
|
char *ret = NULL;
|
||||||
|
|
||||||
|
//std::printf("m_first %p\n", m_first);
|
||||||
|
for (memblock *p = m_first; p != NULL && ret == NULL; p = p->next)
|
||||||
{
|
{
|
||||||
|
if (p->remaining > n)
|
||||||
|
{
|
||||||
|
ret = p->cur;
|
||||||
|
p->cur += n;
|
||||||
|
p->allocated += 1;
|
||||||
|
p->remaining -= n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == NULL)
|
||||||
|
{
|
||||||
|
// need to allocate a new block
|
||||||
|
memblock *p = (memblock *) malloc(min_alloc); //new char[min_alloc];
|
||||||
|
p->allocated = 0;
|
||||||
|
p->cur = &p->data[0];
|
||||||
|
p->size = p->remaining = min_alloc - sizeof(memblock);
|
||||||
|
p->next = m_first;
|
||||||
|
//std::printf("allocated block size %d\n", p->size);
|
||||||
|
|
||||||
ret = p->cur;
|
ret = p->cur;
|
||||||
p->cur += n;
|
p->cur += n;
|
||||||
p->allocated += 1;
|
p->allocated += 1;
|
||||||
p->remaining -= n;
|
p->remaining -= n;
|
||||||
|
|
||||||
|
m_first = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == NULL)
|
|
||||||
{
|
|
||||||
// need to allocate a new block
|
|
||||||
memblock *p = (memblock *) malloc(min_alloc); //new char[min_alloc];
|
|
||||||
p->allocated = 0;
|
|
||||||
p->cur = &p->data[0];
|
|
||||||
p->size = p->remaining = min_alloc - sizeof(memblock);
|
|
||||||
p->next = m_first;
|
|
||||||
//std::printf("allocated block size %d\n", p->size);
|
|
||||||
|
|
||||||
ret = p->cur;
|
|
||||||
p->cur += n;
|
|
||||||
p->allocated += 1;
|
|
||||||
p->remaining -= n;
|
|
||||||
|
|
||||||
m_first = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pstring::dealloc_str(void *ptr)
|
void pstring::dealloc_str(void *ptr)
|
||||||
{
|
{
|
||||||
#if (IMMEDIATE_MODE)
|
if (IMMEDIATE_MODE)
|
||||||
free(ptr);
|
free(ptr);
|
||||||
#else
|
else
|
||||||
for (memblock *p = m_first; p != NULL; p = p->next)
|
|
||||||
{
|
{
|
||||||
if (ptr >= &p->data[0] && ptr < &p->data[p->size])
|
for (memblock *p = m_first; p != NULL; p = p->next)
|
||||||
{
|
{
|
||||||
p->allocated -= 1;
|
if (ptr >= &p->data[0] && ptr < &p->data[p->size])
|
||||||
if (p->allocated < 0)
|
|
||||||
fatalerror("nstring: memory corruption\n");
|
|
||||||
if (p->allocated == 0)
|
|
||||||
{
|
{
|
||||||
//std::printf("Block entirely freed\n");
|
p->allocated -= 1;
|
||||||
p->remaining = p->size;
|
if (p->allocated < 0)
|
||||||
p->cur = &p->data[0];
|
fatalerror("nstring: memory corruption\n");
|
||||||
|
if (p->allocated == 0)
|
||||||
|
{
|
||||||
|
//std::printf("Block entirely freed\n");
|
||||||
|
p->remaining = p->size;
|
||||||
|
p->cur = &p->data[0];
|
||||||
|
}
|
||||||
|
// shutting down ?
|
||||||
|
if (m_zero == NULL)
|
||||||
|
resetmem(); // try to free blocks
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// shutting down ?
|
|
||||||
if (m_zero == NULL)
|
|
||||||
resetmem(); // try to free blocks
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
fatalerror("nstring: string <%p> not found\n", ptr);
|
||||||
}
|
}
|
||||||
fatalerror("nstring: string <%p> not found\n", ptr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pstring::resetmem()
|
void pstring::resetmem()
|
||||||
{
|
{
|
||||||
#if (IMMEDIATE_MODE)
|
if (!IMMEDIATE_MODE)
|
||||||
#else
|
|
||||||
memblock **p = &m_first;
|
|
||||||
int totalblocks = 0;
|
|
||||||
int freedblocks = 0;
|
|
||||||
|
|
||||||
// Release the 0 string
|
|
||||||
if (m_zero != NULL) sfree(m_zero);
|
|
||||||
m_zero = NULL;
|
|
||||||
|
|
||||||
while (*p != NULL)
|
|
||||||
{
|
{
|
||||||
totalblocks++;
|
memblock **p = &m_first;
|
||||||
memblock **next = &((*p)->next);
|
int totalblocks = 0;
|
||||||
if ((*p)->allocated == 0)
|
int freedblocks = 0;
|
||||||
|
|
||||||
|
// Release the 0 string
|
||||||
|
if (m_zero != NULL) sfree(m_zero);
|
||||||
|
m_zero = NULL;
|
||||||
|
|
||||||
|
while (*p != NULL)
|
||||||
{
|
{
|
||||||
//std::printf("freeing block %p\n", *p);
|
totalblocks++;
|
||||||
memblock *freeme = *p;
|
memblock **next = &((*p)->next);
|
||||||
*p = *next;
|
if ((*p)->allocated == 0)
|
||||||
free(freeme); //delete[] *p;
|
{
|
||||||
freedblocks++;
|
//std::printf("freeing block %p\n", *p);
|
||||||
}
|
memblock *freeme = *p;
|
||||||
else
|
*p = *next;
|
||||||
{
|
free(freeme); //delete[] *p;
|
||||||
#if (DEBUG_MODE)
|
freedblocks++;
|
||||||
std::printf("Allocated: <%s>\n", ((str_t *)(&(*p)->data[0]))->str());
|
}
|
||||||
#endif
|
else
|
||||||
p = next;
|
{
|
||||||
|
if (DEBUG_MODE)
|
||||||
|
std::printf("Allocated: <%s>\n", ((str_t *)(&(*p)->data[0]))->str());
|
||||||
|
|
||||||
|
p = next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (DEBUG_MODE)
|
||||||
|
std::printf("Freed %d out of total %d blocks\n", freedblocks, totalblocks);
|
||||||
}
|
}
|
||||||
#if (DEBUG_MODE)
|
|
||||||
std::printf("Freed %d out of total %d blocks\n", freedblocks, totalblocks);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user