[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: pcb plugin smartdisperse fails on load



On Thu, 2011-02-24 at 03:48 +0100, Kai-Martin Knaak wrote:
> Hi.
> 
> I'd love to use the smartdisperse plugin by Ben Jackson for my 
> current project (component count 1755). Compile was fine except 
> for one of these pointer warnings c is infamous for:

> /---------------
> $ gcc -I /usr/local/pcb-src/pcjc2/  -I /usr/local/pcb-src/pcjc2/src/ -I /usr/local/bin -O2 -shared smartdisperse.c -o smartdisperse.so
> smartdisperse.c: In function âsmartdisperseâ:
> smartdisperse.c:149: warning: assignment makes pointer from integer without a cast
> \----------------

Means C didn't find the function, and it assumes it returns integer in
that case. Dumb convention IMO.

> Unfortunately, the plugin fails on load. If I start pcb I get this 
> message on stdout:
>  dl_error: /home/kmk/.pcb/plugins/smartdisperse.so: undefined symbol: MyCalloc
> 
> Consequently, it stays unknown to the command line in the GUI.
> 
> I vaguely remember some talk on the list to replace memory allocation 
> functions. Does this happen to be a collateral damage? 

Yes, it is. We should probably keep some plugins with the PCB source and
have them build as part of the compile - that way we could fix them in
tree when doing refactoring like this.

Replace the MyCalloc call with "calloc". For reference:


commit 0c62fca0df9bd9ebe7bedfbee0af3502e4298a42
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Tue Dec 7 01:47:28 2010 +0000

    Remove My* memory allocation routines. Just use the standard APIs directly
    
    This means the following changes:
    
      1.  Replace all calls to MyCalloc()  with calls to calloc()
      2.  Replace all calls to MyMalloc()  with calls to malloc()
      3.  Replace all calls to MyRealloc() with calls to realloc()
      4.  Replace all calls to SaveFree()  with calls to free()
    
      5a. Where the MYFREE(x) macro is used and its pointer clearing side-
          effect is required, call free (x); and (x) = NULL; directly.
      5b. Where the MYFREE(x) macro is used, and (x) is immediately re-
          assigned, or its location free'd or zero'd, skip the (x) = NULL;
    
      6. Replace all calls to MyStrdup() with calls to the STRDUP(x) macro,
         which expands to (((x) != NULL) ? strdup (x) : NULL).
    
    NB: The previous commit already replaced various known "safe" calls of
        MyStrdup() with strdup(), when the argument is known to be non-NULL.
    
      1,2,3 and 6. mean that we discard the following features of the
      mymem.c allocators:
    
        7. Logging messages when MEM_DEBUF defined
        8. Logic to assign 1 unit of memory if 0 is requested
        9. Allocation failure handling via MyFatal() -> EmergencySave()
    
    
    With feedback from Stephen Ecob <silicon.on.inspiration@xxxxxxxxx>
    
    7. Is old debug code which is rarely (if ever) used. Current debug tools
       such as Valgrind can do a much better job of memory debugging now.
    
    8. This is really papering over the possibility of a caller bug, and
       should never have been included in the first place.
    
    9. This is unlikely to actually ever save someone from loosing their PCB.
    
    Patch created with the assistance and testing of
    Stephen Ecob <silicon.on.inspiration@xxxxxxxxx>


-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
Tel: +44 (0)1223 748328 - (Shared lab phone, ask for me)

Attachment: signature.asc
Description: This is a digitally signed message part


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user