jckarter/clay — pull request #442 by stepancheg (2012-11-10 17:31:06+00:00)
Title: tempCString utility

`tempCString` produces C string for given string. Result is wrapped
in CStringHolder record.

If input is already a C string, then input is simply stored in a
POD CStringHolder.

If input is a string but not a C string, then memory for C string
is allocated, string data is copied to that string, and allocated
C string is stored in CStringHolder record. In this case CStringHolder
owns cstring reference and releases it on destroy.

tempCString is convenient to call C APIs that accept
C strings. Code example:

```
mysqlConnect(host: Pointer[Byte]) { ... }

[S when String?(S)]
myCode(host: S) = mysqlConnect(tempCString(host).ptr);
```

Currently memory is allocated using malloc. Later tempCString may
be rewritten to allocate memory in a thread-local fixed size memory
chunk pool (in this case the cost of memory allocation will be
comparable to `alloca`).