Search code examples
emailqmail

stralloc implementation of string in qmail


what is the ending delimiter of string used through stralloc function in qmail(MTA) code???

stralloc str;
stralloc_copys(&str,"testing");
printf("%s\n", str.s);

It actually prints

testingZjklfjndf

What is the correct way to print the content???


Solution

  • As such there is no delimiter but you can find Z at the end of every string stored by stralloc. the data stored in stralloc is looked-up though len only.

    and as ansh already mentioned dont try to print the data through printf instead run a for loop for len times on the string.

    for more reference: http://cr.yp.to/lib/stralloc.html