kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #07237
Re: operator new in board.cpp
On 12/5/2011 12:30 AM, Dick Hollenbeck wrote:
> Wayne,
>
> I think the lines involving operator new() may blow up at runtime when the corresponding
> delete [] is called.
Dick,
I'm not using
delete[] foo; // This is not the same as delete foo[nn];
where the contents of foo are allocated using
foo = new();
I'm using
delete foo[nn]; // This is the same as tmp* = foo[nn]; delete tmp;
where the contents of the array of foo pointers is assigned using
foo[nn] = new( sizeof(foo) );
In the case of m_BoardSide it is defined in the board class as
MATRIX_CELL* m_BoardSide[MAX_SIDES_COUNT];
so I'm just filling the array of pointers with the new() operator so delete()
should work properly.
>
> Have you tested this code?
I ran the auto router and didn't it segfault and it generated the same results
as the old code so it appears to be correct.
Wayne
>
> You should probably use the
>
> new OBJECT[size]
>
> syntax instead, so the new style matches the delete style.
>
> Dick
>
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
>
Follow ups
References