Changes in / [5b7a60c8:99cad3aa]
- Location:
- src
- Files:
-
- 2 deleted
- 11 edited
-
Common/utility.h (modified) (1 diff)
-
Parser/ExpressionNode.cc (modified) (9 diffs)
-
Parser/ParseNode.h (modified) (1 diff)
-
Parser/StatementNode.cc (modified) (9 diffs)
-
examples/gc_no_raii/containers/vector (deleted)
-
examples/gc_no_raii/containers/vector.c (deleted)
-
examples/gc_no_raii/premake4.lua (modified) (2 diffs)
-
examples/gc_no_raii/src/gc.h (modified) (1 diff)
-
examples/gc_no_raii/src/gcpointers.c (modified) (5 diffs)
-
examples/gc_no_raii/src/gcpointers.h (modified) (2 diffs)
-
examples/gc_no_raii/src/internal/collector.c (modified) (2 diffs)
-
examples/gc_no_raii/src/internal/state.h (modified) (2 diffs)
-
examples/gc_no_raii/test/gctest.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/utility.h
r5b7a60c8 r99cad3aa 49 49 } 50 50 51 template< typename T, typename U >52 static inline T * maybeMoveBuild( const U *orig ) {53 T* ret = maybeBuild<T>(orig);54 delete orig;55 return ret;56 }57 58 59 51 template< typename Input_iterator > 60 52 void printEnums( Input_iterator begin, Input_iterator end, const char * const *name_array, std::ostream &os ) { -
src/Parser/ExpressionNode.cc
r5b7a60c8 r99cad3aa 167 167 168 168 NameExpr * build_varref( const string *name, bool labelp ) { 169 NameExpr *expr = new NameExpr( *name, nullptr ); 170 delete name; 171 return expr; 169 return new NameExpr( *name, nullptr ); 172 170 } 173 171 … … 186 184 if ( dynamic_cast< VoidType * >( targetType ) ) { 187 185 delete targetType; 188 return new CastExpr( maybe MoveBuild< Expression >(expr_node) );186 return new CastExpr( maybeBuild< Expression >(expr_node) ); 189 187 } else { 190 return new CastExpr( maybe MoveBuild< Expression >(expr_node), targetType );188 return new CastExpr( maybeBuild< Expression >(expr_node), targetType ); 191 189 } // if 192 190 } 193 191 194 192 Expression *build_fieldSel( ExpressionNode *expr_node, NameExpr *member ) { 195 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), maybe MoveBuild< Expression >(expr_node) );193 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), maybeBuild< Expression >(expr_node) ); 196 194 delete member; 197 195 return ret; … … 200 198 Expression *build_pfieldSel( ExpressionNode *expr_node, NameExpr *member ) { 201 199 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 202 deref->get_args().push_back( maybe MoveBuild< Expression >(expr_node) );200 deref->get_args().push_back( maybeBuild< Expression >(expr_node) ); 203 201 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref ); 204 202 delete member; … … 207 205 208 206 Expression *build_addressOf( ExpressionNode *expr_node ) { 209 return new AddressExpr( maybe MoveBuild< Expression >(expr_node) );207 return new AddressExpr( maybeBuild< Expression >(expr_node) ); 210 208 } 211 209 Expression *build_sizeOfexpr( ExpressionNode *expr_node ) { 212 return new SizeofExpr( maybe MoveBuild< Expression >(expr_node) );210 return new SizeofExpr( maybeBuild< Expression >(expr_node) ); 213 211 } 214 212 Expression *build_sizeOftype( DeclarationNode *decl_node ) { … … 216 214 } 217 215 Expression *build_alignOfexpr( ExpressionNode *expr_node ) { 218 return new AlignofExpr( maybe MoveBuild< Expression >(expr_node) );216 return new AlignofExpr( maybeBuild< Expression >(expr_node) ); 219 217 } 220 218 Expression *build_alignOftype( DeclarationNode *decl_node ) { … … 226 224 227 225 Expression *build_and_or( ExpressionNode *expr_node1, ExpressionNode *expr_node2, bool kind ) { 228 return new LogicalExpr( notZeroExpr( maybe MoveBuild< Expression >(expr_node1) ), notZeroExpr( maybeMoveBuild< Expression >(expr_node2) ), kind );226 return new LogicalExpr( notZeroExpr( maybeBuild< Expression >(expr_node1) ), notZeroExpr( maybeBuild< Expression >(expr_node2) ), kind ); 229 227 } 230 228 231 229 Expression *build_unary_val( OperKinds op, ExpressionNode *expr_node ) { 232 230 std::list< Expression * > args; 233 args.push_back( maybe MoveBuild< Expression >(expr_node) );231 args.push_back( maybeBuild< Expression >(expr_node) ); 234 232 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 235 233 } 236 234 Expression *build_unary_ptr( OperKinds op, ExpressionNode *expr_node ) { 237 235 std::list< Expression * > args; 238 args.push_back( new AddressExpr( maybe MoveBuild< Expression >(expr_node) ) );236 args.push_back( new AddressExpr( maybeBuild< Expression >(expr_node) ) ); 239 237 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 240 238 } 241 239 Expression *build_binary_val( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) { 242 240 std::list< Expression * > args; 243 args.push_back( maybe MoveBuild< Expression >(expr_node1) );244 args.push_back( maybe MoveBuild< Expression >(expr_node2) );241 args.push_back( maybeBuild< Expression >(expr_node1) ); 242 args.push_back( maybeBuild< Expression >(expr_node2) ); 245 243 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 246 244 } 247 245 Expression *build_binary_ptr( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) { 248 246 std::list< Expression * > args; 249 args.push_back( new AddressExpr( maybe MoveBuild< Expression >(expr_node1) ) );250 args.push_back( maybe MoveBuild< Expression >(expr_node2) );247 args.push_back( new AddressExpr( maybeBuild< Expression >(expr_node1) ) ); 248 args.push_back( maybeBuild< Expression >(expr_node2) ); 251 249 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 252 250 } 253 251 254 252 Expression *build_cond( ExpressionNode *expr_node1, ExpressionNode *expr_node2, ExpressionNode *expr_node3 ) { 255 return new ConditionalExpr( notZeroExpr( maybe MoveBuild< Expression >(expr_node1) ), maybeMoveBuild< Expression >(expr_node2), maybeMoveBuild< Expression >(expr_node3) );253 return new ConditionalExpr( notZeroExpr( maybeBuild< Expression >(expr_node1) ), maybeBuild< Expression >(expr_node2), maybeBuild< Expression >(expr_node3) ); 256 254 } 257 255 258 256 Expression *build_comma( ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) { 259 return new CommaExpr( maybe MoveBuild< Expression >(expr_node1), maybeMoveBuild< Expression >(expr_node2) );257 return new CommaExpr( maybeBuild< Expression >(expr_node1), maybeBuild< Expression >(expr_node2) ); 260 258 } 261 259 262 260 Expression *build_attrexpr( NameExpr *var, ExpressionNode * expr_node ) { 263 return new AttrExpr( var, maybe MoveBuild< Expression >(expr_node) );261 return new AttrExpr( var, maybeBuild< Expression >(expr_node) ); 264 262 } 265 263 Expression *build_attrtype( NameExpr *var, DeclarationNode * decl_node ) { … … 269 267 Expression *build_tuple( ExpressionNode * expr_node ) { 270 268 TupleExpr *ret = new TupleExpr(); 271 build MoveList( expr_node, ret->get_exprs() );269 buildList( expr_node, ret->get_exprs() ); 272 270 return ret; 273 271 } … … 275 273 Expression *build_func( ExpressionNode * function, ExpressionNode * expr_node ) { 276 274 std::list< Expression * > args; 277 buildMoveList( expr_node, args ); 278 return new UntypedExpr( maybeMoveBuild< Expression >(function), args, nullptr ); 275 276 buildList( expr_node, args ); 277 return new UntypedExpr( maybeBuild< Expression >(function), args, nullptr ); 279 278 } 280 279 281 280 Expression *build_range( ExpressionNode * low, ExpressionNode *high ) { 282 return new RangeExpr( maybeMoveBuild< Expression >( low ), maybeMoveBuild< Expression >( high ) ); 281 Expression *low_cexpr = maybeBuild< Expression >( low ); 282 Expression *high_cexpr = maybeBuild< Expression >( high ); 283 return new RangeExpr( low_cexpr, high_cexpr ); 283 284 } 284 285 285 286 Expression *build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ) { 286 return new AsmExpr( maybe MoveBuild< Expression >( inout ), constraint, maybeMoveBuild< Expression >(operand) );287 return new AsmExpr( maybeBuild< Expression >( inout ), constraint, maybeBuild< Expression >(operand) ); 287 288 } 288 289 289 290 Expression *build_valexpr( StatementNode *s ) { 290 return new UntypedValofExpr( maybe MoveBuild< Statement >(s), nullptr );291 return new UntypedValofExpr( maybeBuild< Statement >(s), nullptr ); 291 292 } 292 293 Expression *build_typevalue( DeclarationNode *decl ) { … … 297 298 Declaration * newDecl = maybeBuild< Declaration >(decl_node); // compound literal type 298 299 if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type 299 return new CompoundLiteralExpr( newDeclWithType->get_type(), maybe MoveBuild< Initializer >(kids) );300 return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeBuild< Initializer >(kids) ); 300 301 // these types do not have associated type information 301 302 } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl ) ) { 302 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybe MoveBuild< Initializer >(kids) );303 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeBuild< Initializer >(kids) ); 303 304 } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl ) ) { 304 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybe MoveBuild< Initializer >(kids) );305 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeBuild< Initializer >(kids) ); 305 306 } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl ) ) { 306 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybe MoveBuild< Initializer >(kids) );307 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeBuild< Initializer >(kids) ); 307 308 } else { 308 309 assert( false ); -
src/Parser/ParseNode.h
r5b7a60c8 r99cad3aa 387 387 void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList ); 388 388 389 template< typename SynTreeType, typename NodeType >390 void buildMoveList( const NodeType *firstNode, std::list< SynTreeType * > &outputList ) {391 buildList(firstNode, outputList);392 delete firstNode;393 }394 395 396 389 #endif // PARSENODE_H 397 390 -
src/Parser/StatementNode.cc
r5b7a60c8 r99cad3aa 62 62 StatementNode *node = dynamic_cast< StatementNode * >(prev); 63 63 std::list< Statement * > stmts; 64 build MoveList( stmt, stmts );64 buildList( stmt, stmts ); 65 65 // splice any new Statements to end of current Statements 66 66 CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt); … … 70 70 71 71 Statement *build_expr( ExpressionNode *ctl ) { 72 Expression *e = maybe MoveBuild< Expression >( ctl );72 Expression *e = maybeBuild< Expression >( ctl ); 73 73 74 74 if ( e ) … … 81 81 Statement *thenb, *elseb = 0; 82 82 std::list< Statement * > branches; 83 build MoveList< Statement, StatementNode >( then_stmt, branches );83 buildList< Statement, StatementNode >( then_stmt, branches ); 84 84 assert( branches.size() == 1 ); 85 85 thenb = branches.front(); … … 87 87 if ( else_stmt ) { 88 88 std::list< Statement * > branches; 89 build MoveList< Statement, StatementNode >( else_stmt, branches );89 buildList< Statement, StatementNode >( else_stmt, branches ); 90 90 assert( branches.size() == 1 ); 91 91 elseb = branches.front(); 92 92 } // if 93 return new IfStmt( noLabels, notZeroExpr( maybe MoveBuild< Expression >(ctl) ), thenb, elseb );93 return new IfStmt( noLabels, notZeroExpr( maybeBuild< Expression >(ctl) ), thenb, elseb ); 94 94 } 95 95 96 96 Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) { 97 97 std::list< Statement * > branches; 98 build MoveList< Statement, StatementNode >( stmt, branches );98 buildList< Statement, StatementNode >( stmt, branches ); 99 99 assert( branches.size() >= 0 ); // size == 0 for switch (...) {}, i.e., no declaration or statements 100 return new SwitchStmt( noLabels, maybe MoveBuild< Expression >(ctl), branches );100 return new SwitchStmt( noLabels, maybeBuild< Expression >(ctl), branches ); 101 101 } 102 102 Statement *build_case( ExpressionNode *ctl ) { 103 103 std::list< Statement * > branches; 104 return new CaseStmt( noLabels, maybe MoveBuild< Expression >(ctl), branches );104 return new CaseStmt( noLabels, maybeBuild< Expression >(ctl), branches ); 105 105 } 106 106 Statement *build_default() { … … 111 111 Statement *build_while( ExpressionNode *ctl, StatementNode *stmt, bool kind ) { 112 112 std::list< Statement * > branches; 113 build MoveList< Statement, StatementNode >( stmt, branches );113 buildList< Statement, StatementNode >( stmt, branches ); 114 114 assert( branches.size() == 1 ); 115 return new WhileStmt( noLabels, notZeroExpr( maybe MoveBuild< Expression >(ctl) ), branches.front(), kind );115 return new WhileStmt( noLabels, notZeroExpr( maybeBuild< Expression >(ctl) ), branches.front(), kind ); 116 116 } 117 117 118 118 Statement *build_for( ForCtl *forctl, StatementNode *stmt ) { 119 119 std::list< Statement * > branches; 120 build MoveList< Statement, StatementNode >( stmt, branches );120 buildList< Statement, StatementNode >( stmt, branches ); 121 121 assert( branches.size() == 1 ); 122 122 123 123 std::list< Statement * > init; 124 124 if ( forctl->init != 0 ) { 125 build MoveList( forctl->init, init );125 buildList( forctl->init, init ); 126 126 } // if 127 127 128 128 Expression *cond = 0; 129 129 if ( forctl->condition != 0 ) 130 cond = notZeroExpr( maybe MoveBuild< Expression >(forctl->condition) );130 cond = notZeroExpr( maybeBuild< Expression >(forctl->condition) ); 131 131 132 132 Expression *incr = 0; 133 133 if ( forctl->change != 0 ) 134 incr = maybe MoveBuild< Expression >(forctl->change);134 incr = maybeBuild< Expression >(forctl->change); 135 135 136 136 delete forctl; … … 142 142 } 143 143 Statement *build_computedgoto( ExpressionNode *ctl ) { 144 return new BranchStmt( noLabels, maybe MoveBuild< Expression >(ctl), BranchStmt::Goto );144 return new BranchStmt( noLabels, maybeBuild< Expression >(ctl), BranchStmt::Goto ); 145 145 } 146 146 147 147 Statement *build_return( ExpressionNode *ctl ) { 148 148 std::list< Expression * > exps; 149 build MoveList( ctl, exps );149 buildList( ctl, exps ); 150 150 return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr ); 151 151 } 152 152 Statement *build_throw( ExpressionNode *ctl ) { 153 153 std::list< Expression * > exps; 154 build MoveList( ctl, exps );154 buildList( ctl, exps ); 155 155 return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr, true ); 156 156 } … … 158 158 Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) { 159 159 std::list< Statement * > branches; 160 build MoveList< Statement, StatementNode >( catch_stmt, branches );161 CompoundStmt *tryBlock = dynamic_cast< CompoundStmt * >(maybe MoveBuild< Statement >(try_stmt));160 buildList< Statement, StatementNode >( catch_stmt, branches ); 161 CompoundStmt *tryBlock = dynamic_cast< CompoundStmt * >(maybeBuild< Statement >(try_stmt)); 162 162 assert( tryBlock ); 163 FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybe MoveBuild< Statement >(finally_stmt) );163 FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeBuild< Statement >(finally_stmt) ); 164 164 return new TryStmt( noLabels, tryBlock, branches, finallyBlock ); 165 165 } 166 166 Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny ) { 167 167 std::list< Statement * > branches; 168 build MoveList< Statement, StatementNode >( stmt, branches );168 buildList< Statement, StatementNode >( stmt, branches ); 169 169 assert( branches.size() == 1 ); 170 return new CatchStmt( noLabels, maybe MoveBuild< Declaration >(decl), branches.front(), catchAny );170 return new CatchStmt( noLabels, maybeBuild< Declaration >(decl), branches.front(), catchAny ); 171 171 } 172 172 Statement *build_finally( StatementNode *stmt ) { 173 173 std::list< Statement * > branches; 174 build MoveList< Statement, StatementNode >( stmt, branches );174 buildList< Statement, StatementNode >( stmt, branches ); 175 175 assert( branches.size() == 1 ); 176 176 return new FinallyStmt( noLabels, dynamic_cast< CompoundStmt * >( branches.front() ) ); … … 179 179 Statement *build_compound( StatementNode *first ) { 180 180 CompoundStmt *cs = new CompoundStmt( noLabels ); 181 build MoveList( first, cs->get_kids() );181 buildList( first, cs->get_kids() ); 182 182 return cs; 183 183 } … … 187 187 std::list< ConstantExpr * > clob; 188 188 189 build MoveList( output, out );190 build MoveList( input, in );191 build MoveList( clobber, clob );189 buildList( output, out ); 190 buildList( input, in ); 191 buildList( clobber, clob ); 192 192 return new AsmStmt( noLabels, voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels ); 193 193 } -
src/examples/gc_no_raii/premake4.lua
r5b7a60c8 r99cad3aa 6 6 "src/", 7 7 "../", 8 "containers/"9 8 } 10 9 … … 49 48 linkoptions (linkOptionList) 50 49 includedirs (includeDirList) 51 files { "src/**.c" , "containers/**.c"}50 files { "src/**.c" } 52 51 53 52 configuration "debug" -
src/examples/gc_no_raii/src/gc.h
r5b7a60c8 r99cad3aa 4 4 #include "internal/collector.h" 5 5 6 //forall(otype T)7 //static inline gcpointer(T) gcmalloc()8 //{9 //gcpointer(T) ptr = { gc_allocate(sizeof(T)) };10 //ptr{};11 //gc_conditional_collect();12 //return ptr;13 //}6 forall(otype T) 7 static inline gcpointer(T) gcmalloc() 8 { 9 gcpointer(T) ptr = { gc_allocate(sizeof(T)) }; 10 ptr{}; 11 gc_conditional_collect(); 12 return ptr; 13 } 14 14 15 15 forall(otype T) 16 16 static inline void gcmalloc(gcpointer(T)* ptr) 17 17 { 18 ptr { gc_allocate(sizeof(T)) };19 get(ptr){};18 ptr{ gc_allocate(sizeof(T)) }; 19 (*ptr){}; 20 20 gc_conditional_collect(); 21 21 } -
src/examples/gc_no_raii/src/gcpointers.c
r5b7a60c8 r99cad3aa 42 42 } 43 43 44 void ?{}(gcpointer_t* this)44 void gcpointer_ctor(gcpointer_t* this) 45 45 { 46 46 this->ptr = (intptr_t)NULL; … … 48 48 } 49 49 50 void ?{}(gcpointer_t* this, void* address)50 void gcpointer_ctor(gcpointer_t* this, void* address) 51 51 { 52 52 this->ptr = (intptr_t)address; … … 56 56 } 57 57 58 void ?{}(gcpointer_t* this, gcpointer_tother)58 void gcpointer_ctor(gcpointer_t* this, gcpointer_t* other) 59 59 { 60 this->ptr = other .ptr;60 this->ptr = other->ptr; 61 61 this->next = NULL; 62 62 … … 64 64 } 65 65 66 void ^?{}(gcpointer_t* this)66 void gcpointer_dtor(gcpointer_t* this) 67 67 { 68 68 unregister_ptr(this); … … 98 98 return this->ptr == (intptr_t)NULL; 99 99 } 100 101 forall(otype T) void ?{}(gcpointer(T)* this) {102 (&this->internal) {};103 }104 105 forall(otype T) void ?{}(gcpointer(T)* this, void* address) {106 (&this->internal) { address };107 }108 109 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other) {110 (&this->internal) { other->internal };111 }112 113 forall(otype T) void ^?{}(gcpointer(T)* this) {114 ^?{}(&this->internal);115 }116 117 // forall(otype T) gcpointer(T) ?=?(gcpointer(T) this, gcpointer(T) rhs);118 //119 // forall(otype T) T *?(gcpointer(T) this);120 121 forall(otype T) T* get(gcpointer(T)* this) {122 return (T*)this->internal.ptr;123 }124 //125 // //Logical operators126 // forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs);127 // forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs); -
src/examples/gc_no_raii/src/gcpointers.h
r5b7a60c8 r99cad3aa 30 30 forall(otype T) void ?{}(gcpointer(T)* this); 31 31 forall(otype T) void ?{}(gcpointer(T)* this, void* address); 32 forall(otype T) void ctor(gcpointer(T)* this, void* address); 32 33 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other); 33 34 forall(otype T) void ^?{}(gcpointer(T)* this); … … 36 37 37 38 forall(otype T) T *?(gcpointer(T) this); 38 forall(otype T) T* get(gcpointer(T)* this);39 39 40 40 //Logical operators -
src/examples/gc_no_raii/src/internal/collector.c
r5b7a60c8 r99cad3aa 8 8 } 9 9 #endif 10 11 #include <fstream>12 10 13 11 #include "state.h" … … 38 36 void* gc_allocate(size_t target_size) 39 37 { 40 sout | "Allocating " | target_size | " bytes" | endl;41 42 38 size_t size = gc_compute_size(target_size + sizeof(gc_object_header)); 43 44 sout | "Object header size: " | sizeof(gc_object_header) | " bytes" | endl;45 sout | "Actual allocation size: " | size | " bytes" | endl;46 39 47 40 check(size < POOL_SIZE_BYTES); -
src/examples/gc_no_raii/src/internal/state.h
r5b7a60c8 r99cad3aa 9 9 } 10 10 #endif 11 #include <fstream>12 11 #include <vector> 13 12 … … 38 37 static inline bool gc_needs_collect(gc_state* state) 39 38 { 40 sout | "Used Space: " | state->used_space | " bytes" | endl;41 39 return state->used_space * 2 > state->total_space; 42 40 } -
src/examples/gc_no_raii/test/gctest.c
r5b7a60c8 r99cad3aa 2 2 3 3 #include "gc.h" 4 #include "internal/collector.h"5 4 6 5 #warning default test … … 9 8 sout | "Bonjour au monde!\n"; 10 9 11 gcpointer(int) theInt; 12 gcmalloc(&theInt); 13 14 for(int i = 0; i < 10; i++) { 15 int a; 16 { 17 gcpointer(int) anInt; 18 gcmalloc(&anInt); 19 } 20 int p; 10 for(int i = 0; i < 1000000; i++) { 11 gcpointer(int) anInt; 12 gcmalloc(&anInt); 21 13 } 22 23 gc_collect(gc_get_state());24 gc_conditional_collect();25 14 }
Note:
See TracChangeset
for help on using the changeset viewer.