Problem with Hiredis Binding

Joshua Reusch yoschi at arkandos.de
Thu Jan 5 11:24:46 PST 2012


Am 05.01.2012 19:44, schrieb Timon Gehr:
> On 01/05/2012 07:14 PM, Joshua Reusch wrote:
>> Am 05.01.2012 17:21, schrieb Puming Zhao:
>>> Hi, I'm new in D programming, and does not have much C experience
>>> either. After
>>> reading TDPL book and playing with some sample codes, I came to decide
>>> to try
>>> something more `practical`. I began with a Redis client binding from
>>> Hiredis C code.
>>> Hiredis is a small lib, and seems very simple to bind to D.
>>>
>>> My code on github:
>>>
>>> https://github.com/zhaopuming/dredis
>>>
>>> But I went into problems that I don't know how to solve. When running
>>> example.d I
>>> went into segment fault, and can't get redisReply from a redis
>>> command. I tried to
>>> google it but got nothing.
>>>
>>> So my question is, could some one with more knowledge in redis or C/D
>>> look into my
>>> code and see what's wrong ? Or is there already a Redis binding exists?
>>
>> dredis.d:
>> > redisContext* redisConnectWithTimeout(const char* ip, int port,
>> timeval tv);
>>
>> example.d:
>> > redisConnectWithTimeout("127.0.0.1", 6379, timeout);
>>
>>
>> D strings do not end with an \0 byte !
>> You can use std.string.toStringz to convert them to C's const char*
>>
>> -- Joshua
>
> D string literals are zero-terminated.

Sure ? dlang.org says they are not: 
http://www.d-programming-language.org/arrays.html#strings


More information about the Digitalmars-d-learn mailing list