Project

General

Profile

« Previous | Next » 

Revision 80f93e0a

Added by Xavier Thirioux almost 8 years ago

added deallocation for dynamic memory allocation scheme

View differences:

src/backends/C/c_backend_common.ml
94 94
let pp_machine_memtype_name fmt id = fprintf fmt "struct %s_mem" id
95 95
let pp_machine_regtype_name fmt id = fprintf fmt "struct %s_reg" id
96 96
let pp_machine_alloc_name fmt id = fprintf fmt "%s_alloc" id
97
let pp_machine_dealloc_name fmt id = fprintf fmt "%s_dealloc" id
97 98
let pp_machine_static_declare_name fmt id = fprintf fmt "%s_DECLARE" id
98 99
let pp_machine_static_link_name fmt id = fprintf fmt "%s_LINK" id
99 100
let pp_machine_static_alloc_name fmt id = fprintf fmt "%s_ALLOC" id
......
348 349
    pp_machine_alloc_name name
349 350
    (Utils.fprintf_list ~sep:",@ " pp_c_decl_input_var) static
350 351

  
352
let print_dealloc_prototype fmt name =
353
  fprintf fmt "void %a (%a * _alloc)"
354
    pp_machine_dealloc_name name
355
    pp_machine_memtype_name name
356
    
351 357
let print_reset_prototype self fmt (name, static) =
352 358
  fprintf fmt "void %a (@[<v>%a%t%a *%s@])"
353 359
    pp_machine_reset_name name
......
422 428
let print_extern_alloc_prototypes fmt (Dep (_,_, header,_)) =
423 429
  List.iter (fun decl -> match decl.top_decl_desc with
424 430
  | ImportedNode ind when not ind.nodei_stateless ->
425
    let static = List.filter (fun v -> v.var_dec_const) ind.nodei_inputs
426
    in fprintf fmt "extern %a;@." print_alloc_prototype (ind.nodei_id, static)
431
    let static = List.filter (fun v -> v.var_dec_const) ind.nodei_inputs in
432
    begin
433
      fprintf fmt "extern %a;@.@." print_alloc_prototype (ind.nodei_id, static);
434
      fprintf fmt "extern %a;@.@." print_dealloc_prototype ind.nodei_id;
435
    end
427 436
  | _                -> ()
428 437
  ) header
429 438

  

Also available in: Unified diff