On Thu, 13 May 2010, Mathieu Bouchard wrote:
On Thu, 13 May 2010, Hans-Christoph Steiner wrote:
Or maybe:
      binbuf_gettext(bb, &buf, &bufsize);
      strncat(buf, "\0", strlen(buf)-bufsize);
strncat will copy at most strlen(buf)-bufsize, but it will also copy at most strlen("\0") bytes, and strlen("\0") is zero, because strlen actually is just
 long strlen (const char *start) {
   const char *end = start;
   while (*end) end++;
   return end-start;
 }

... but also, strncat(buf,...) needs a well-defined strlen(buf) in the first place, which only exists if buf has a null terminator before you start. only in this case, strncat will be guaranteed to have the correct behaviour, which is to have no effect at all in this case.

 _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard, Montréal, Québec. téléphone: +1.514.383.3801
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to