Netlist generator: avoid changing the order of parts in libparts section each time libraries are reloaded.
pic_programmer demo: very minor fix and update netlist. cached_container.cpp: more info when the message "Out of memory" is displayed.
This commit is contained in:
parent
08178104bb
commit
ecad3ad235
|
@ -308,11 +308,14 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget )
|
|||
if( aTarget == NULL )
|
||||
{
|
||||
// No target was specified, so we have to reallocate our own space
|
||||
aTarget = static_cast<VERTEX*>( malloc( m_currentSize * sizeof( VERTEX ) ) );
|
||||
int size = m_currentSize * sizeof( VERTEX );
|
||||
aTarget = static_cast<VERTEX*>( malloc( size ) );
|
||||
|
||||
if( aTarget == NULL )
|
||||
{
|
||||
DisplayError( NULL, wxT( "Run out of memory" ) );
|
||||
DisplayError( NULL, wxString::Format(
|
||||
wxT( "CACHED_CONTAINER::defragment: Run out of memory (malloc %d bytes)" ),
|
||||
size ) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -432,11 +435,15 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
|
|||
if( reservedSpace() > aNewSize )
|
||||
return false;
|
||||
|
||||
newContainer = static_cast<VERTEX*>( malloc( aNewSize * sizeof( VERTEX ) ) );
|
||||
int size = aNewSize * sizeof( VERTEX );
|
||||
newContainer = static_cast<VERTEX*>( malloc( size ) );
|
||||
|
||||
if( newContainer == NULL )
|
||||
{
|
||||
DisplayError( NULL, wxT( "Run out of memory" ) );
|
||||
DisplayError( NULL, wxString::Format(
|
||||
wxT( "CACHED_CONTAINER::resizeContainer:\n"
|
||||
"Run out of memory (malloc %d bytes)" ),
|
||||
size ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -451,11 +458,15 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
|
|||
else
|
||||
{
|
||||
// Enlarging container
|
||||
newContainer = static_cast<VERTEX*>( realloc( m_vertices, aNewSize * sizeof( VERTEX ) ) );
|
||||
int size = aNewSize * sizeof( VERTEX );
|
||||
newContainer = static_cast<VERTEX*>( realloc( m_vertices, size ) );
|
||||
|
||||
if( newContainer == NULL )
|
||||
{
|
||||
DisplayError( NULL, wxT( "Run out of memory" ) );
|
||||
DisplayError( NULL, wxString::Format(
|
||||
wxT( "CACHED_CONTAINER::resizeContainer:\n"
|
||||
"Run out of memory (realloc from %d to %d bytes)" ),
|
||||
m_currentSize * sizeof( VERTEX ), size ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -235,7 +235,7 @@ L C C9
|
|||
U 1 1 464AD280
|
||||
P 5700 1000
|
||||
F 0 "C9" H 5750 1100 50 0000 L CNN
|
||||
F 1 "22OnF" H 5750 900 50 0000 L CNN
|
||||
F 1 "220nF" H 5750 900 50 0000 L CNN
|
||||
F 2 "discret:C1-1" H 5500 900 30 0000 C CNN
|
||||
F 3 "" H 5700 1000 60 0001 C CNN
|
||||
1 5700 1000
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <kicad_string.h>
|
||||
|
||||
#include <class_libentry.h>
|
||||
#include <class_netlist_object.h>
|
||||
#include <lib_pin.h>
|
||||
#include <sch_component.h>
|
||||
|
@ -65,6 +66,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct LIB_PART_LESS_THAN
|
||||
* is used by std:set<LIB_PART*> instantiation which uses LIB_PART name as its key.
|
||||
*/
|
||||
struct LIB_PART_LESS_THAN
|
||||
{
|
||||
// a "less than" test on two LIB_PARTs (.m_name wxStrings)
|
||||
bool operator()( LIB_PART* const& libpart1, LIB_PART* const& libpart2 ) const
|
||||
{
|
||||
// Use case specific GetName() wxString compare
|
||||
return libpart1->GetName().Cmp( libpart2->GetName() ) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Class NETLIST_EXPORTER
|
||||
|
@ -86,10 +100,10 @@ protected:
|
|||
/// avoids processing a lib component more than once.
|
||||
UNIQUE_STRINGS m_ReferencesAlreadyFound;
|
||||
|
||||
/// unique library parts used. LIB_PART items are sorted by names
|
||||
std::set<LIB_PART*, LIB_PART_LESS_THAN> m_LibParts;
|
||||
|
||||
// share a code generated std::set<void*> to reduce code volume
|
||||
|
||||
std::set<void*> m_LibParts; ///< unique library parts used
|
||||
|
||||
std::set<void*> m_Libraries; ///< unique libraries used
|
||||
|
||||
/**
|
||||
|
|
|
@ -308,9 +308,9 @@ XNODE* NETLIST_EXPORTER_GENERIC::makeLibParts()
|
|||
|
||||
m_Libraries.clear();
|
||||
|
||||
for( std::set<void*>::iterator it = m_LibParts.begin(); it!=m_LibParts.end(); ++it )
|
||||
for( std::set<LIB_PART*>::iterator it = m_LibParts.begin(); it!=m_LibParts.end(); ++it )
|
||||
{
|
||||
LIB_PART* lcomp = (LIB_PART* ) *it;
|
||||
LIB_PART* lcomp = *it;
|
||||
PART_LIB* library = lcomp->GetLib();
|
||||
|
||||
m_Libraries.insert( library ); // inserts component's library if unique
|
||||
|
|
Loading…
Reference in New Issue