Am 03.06.2013 20:45, schrieb Paul B. Henson:
> On 6/3/2013 3:48 AM, walter harms wrote:
> 
>>> +            p = path + sprintf(path, "/sys/class/ubi/ubi%d/", num);
>>> +
>>> +            strcpy(p, "avail_eraseblocks");
>>
>> you can use xasprintf() here ?
> 
> I dunno, Mike said to use sprintf/strcpy to avoid copying the same
> string prefix twice.
> 
> What would be the benefit of allocating the space for the string off of
> the heap instead of the stack?
> 

I do not see the whole code but so far i understand you
like to construct one string with some additional stuff.

IMHO it is most times more easy and less error-prone to
construct the strings with asprintf() instead of adding as
pieces together by hand. This is clearly no true for every
problem. Please think about the problem it is ok when you
conclude that it is not working.

re,
 wh




_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to