Add a long long as integer reply or bulk len / multi bulk count. * Basically this is used to output . */
| 882 | /* Add a long long as integer reply or bulk len / multi bulk count. |
| 883 | * Basically this is used to output <prefix><long long><crlf>. */ |
| 884 | void addReplyLongLongWithPrefix(client *c, long long ll, char prefix) { |
| 885 | char buf[128]; |
| 886 | int len; |
| 887 | |
| 888 | /* Things like $3\r\n or *2\r\n are emitted very often by the protocol |
| 889 | * so we have a few shared objects to use if the integer is small |
| 890 | * like it is most of the times. */ |
| 891 | if (prefix == '*' && ll < OBJ_SHARED_BULKHDR_LEN && ll >= 0) { |
| 892 | addReply(c,shared.mbulkhdr[ll]); |
| 893 | return; |
| 894 | } else if (prefix == '$' && ll < OBJ_SHARED_BULKHDR_LEN && ll >= 0) { |
| 895 | addReply(c,shared.bulkhdr[ll]); |
| 896 | return; |
| 897 | } |
| 898 | |
| 899 | buf[0] = prefix; |
| 900 | len = ll2string(buf+1,sizeof(buf)-1,ll); |
| 901 | buf[len+1] = '\r'; |
| 902 | buf[len+2] = '\n'; |
| 903 | addReplyProto(c,buf,len+3); |
| 904 | } |
| 905 | |
| 906 | void addReplyLongLong(client *c, long long ll) { |
| 907 | if (ll == 0) |
no test coverage detected