mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Stop using placement new like a weirdo
This commit is contained in:
parent
3adf6d25f6
commit
562ba1291e
1 changed files with 5 additions and 10 deletions
15
reader.cpp
15
reader.cpp
|
@ -2277,13 +2277,9 @@ static int default_test( wchar_t *b )
|
|||
|
||||
void reader_push( const wchar_t *name )
|
||||
{
|
||||
// use placement new to guarantee zero initialization :(
|
||||
void *buff = calloc(1, sizeof(reader_data_t));
|
||||
if( !buff )
|
||||
{
|
||||
DIE_MEM();
|
||||
}
|
||||
reader_data_t *n = new(buff) reader_data_t;
|
||||
// use something nasty which guarantees value initialization (that is, all fields zero)
|
||||
reader_data_t zerod = {};
|
||||
reader_data_t *n = new reader_data_t(zerod);
|
||||
|
||||
n->app_name = name;
|
||||
n->next = data;
|
||||
|
@ -2337,9 +2333,8 @@ void reader_pop()
|
|||
al_destroy( &n->search_prev );
|
||||
free( (void *)n->token_history_buff);
|
||||
|
||||
/* Invoke the destructor to balance our placement new */
|
||||
n->~reader_data_t();
|
||||
free(n);
|
||||
/* Invoke the destructor to balance our new */
|
||||
delete n;
|
||||
|
||||
if( data == 0 )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue