Reference to pointer in dxf_*_free incomplete

Bug #1417390 reported by Bert Timmerman
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Won't Fix
Bert Timmerman

Bug Description


I'm getting the impression that pointers to structs are not properly referenced in dxf_*_free() functions.

As is now:

dxf_arc_free (DxfArc *dxf_arc)

Probably has to become:

dxf_arc_free (DxfArc **dxf_arc)

I'm not sure and have to investigate (and test) more.

Maybe someone with more foo on pointers can give some clues how to handle the referencing inside the function.

As it is now, the value of the pointer is not returned from the scope of the function to the caller.

Kind regards,

Bert Timmerman.

Tags: api
tags: added: api
description: updated
Revision history for this message
Nicola Fontana (entidi) wrote :

Hi Bert,

in C is idiomatic to pass a simple pointer, as the free() function does itself. Any C programmer knows that after a free operation the pointer contains junk (and if he does not know, better he stays away from any C code ;).

A related note: I am working on a C project with automatic bindings to other languages (e.g. Lua and Python) and having the straight pointer as first argument is *vital* for letting object oriented style programming automatically work. Not sure it is relevant in your case but... just to let you know.

Another note: actually the implementation of dxf_arc_free() is like

int dxf_arc_free(DxfArc *arc)
    free (arc->linetype);
    free (arc);
    arc = NULL;
    return (EXIT_SUCCESS);

The "arc = NULL" line is a no-op. You are modifying the "arg" argument of dxf_arc_free() that will be destroyed anyway when the function ends.

Changed in libdxf:
status: Triaged → Won't Fix
Changed in libdxf:
milestone: 0.0.1 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.