[dm-devel] Multipath and HSG80 phase 2

Nicola Ranaldo ranaldo at unina.it
Tue Dec 14 16:37:24 UTC 2004


> I have already sent Christophe a patch for this.  The problem was he set 
> p,
> moved p, realloced dst, and expected dst to start at the same memory
> locating it was at before reallocing, which may or may not be true.  The 
> fix
> moves the p assignment and movement after the realloc call.
>
> Andy

I looked at the patch, but it is not sufficient.
In the case realloc returns a new pointer the merge_words works well but the 
original parameter mmp->somethingh will not be changed, so it will point to 
unreferenced memory!
So, in order to change it, we have to work on its pointer modifying the 
function prototype and the relative calls, according to the following patch:

76c76
< merge_words (char * dst, char * word, int space)
---
> merge_words (char ** dst, char * word, int space)
81,82c81,82
<       len = strlen(dst) + strlen(word) + space;
<       dst = realloc(dst, len + 1);
---
>       len = strlen(*dst) + strlen(word) + space;
>       *dst = realloc(*dst, len + 1);
84c84
<       if (!dst)
---
>       if (!*dst)
87c87
<       p = dst;
---
>       p = *dst;
127c127
<               merge_words(mpp->features, word, 1);
---
>               merge_words(&mpp->features, word, 1);
170c170
<                       merge_words(mpp->selector, word, 1);
---
>                       merge_words(&mpp->selector, word, 1);

I'm sorry i realized it only after Chris released version 0.4.0 :(
I'm going to continue in testing overall the package and giving you 
feedback.

Good work

    Nicola Ranaldo




More information about the dm-devel mailing list