Is he him ? viewtopic.php?f=13&t=49338
Hmm... yes he is.
I see has followed (EDIT
: almost) the suggestion in my last post on that thread (after some weeks I finally have an indirect reply about its validity, nice), but he added a memory allocation that I believe is unneeded. The reasons are explained in that same post.
And now that I can see the code available on that site:
int CCONV AttachHandler(CPhidgetHandle Analog, void *userptr)
const char *name;
CPhidget_getDeviceName (Analog, &name);
printf("%s %10d attached!\n", name, serialNo);
you can see there is no external memory allocation here and that the pointer value is altered by the function as I supposed at the time.
I didn't check any of the remaining code, even if I still see the same problem I mentioned on that thread, the *tmp var become tmp (they are two distinct vars and I don't think it is supposed to happen, so I believe there is something wrong here too).
That's why I suggested to use EnableExplicit to help him spot the problems.
Looks like this code has been written without trying to understand what it is really happening at each and every step.EDIT
: Oh wait, I didn't notice. Has done the same with the *name pointer. He allocated the memory to *name
and then used a new var name
as param of the function, instead of using *name
and then @*name
By sheer luck it works (since at this point we can be sure the memory is allocated inside the library) and the original pointer is not altered (being two different variables) but the "memory leak" is still present (memory is allocated without a reason).