mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-27 12:15:08 +00:00
Replaced void*data with auto_ptr<function_data_t>, eliminating antoher halloc.
This commit is contained in:
parent
c0e783eb6e
commit
006523ac59
2 changed files with 6 additions and 4 deletions
|
@ -1792,7 +1792,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
function_data_t * d = (function_data_t *)halloc( parser.current_block, sizeof( function_data_t ));
|
function_data_t *d = new function_data_t();
|
||||||
|
|
||||||
d->name=halloc_wcsdup( parser.current_block, name);
|
d->name=halloc_wcsdup( parser.current_block, name);
|
||||||
d->description=desc?halloc_wcsdup( parser.current_block, desc):0;
|
d->description=desc?halloc_wcsdup( parser.current_block, desc):0;
|
||||||
|
@ -1806,7 +1806,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
|
||||||
e->function_name = d->name;
|
e->function_name = d->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.current_block->data = d;
|
parser.current_block->function_data.reset(d);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3270,7 +3270,7 @@ static int builtin_end( parser_t &parser, wchar_t **argv )
|
||||||
case FUNCTION_DEF:
|
case FUNCTION_DEF:
|
||||||
{
|
{
|
||||||
|
|
||||||
function_data_t *d = (function_data_t *)parser.current_block->data;
|
function_data_t *d = parser.current_block->function_data.get();
|
||||||
|
|
||||||
if( d )
|
if( d )
|
||||||
{
|
{
|
||||||
|
|
4
parser.h
4
parser.h
|
@ -11,8 +11,10 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
#include "function.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#define PARSER_TEST_ERROR 1
|
#define PARSER_TEST_ERROR 1
|
||||||
#define PARSER_TEST_INCOMPLETE 2
|
#define PARSER_TEST_INCOMPLETE 2
|
||||||
|
@ -81,7 +83,7 @@ typedef struct block
|
||||||
/**
|
/**
|
||||||
Block type-specific data
|
Block type-specific data
|
||||||
*/
|
*/
|
||||||
void *data;
|
std::auto_ptr<function_data_t> function_data;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
union
|
union
|
||||||
|
|
Loading…
Reference in a new issue