Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
template <typename F, typename T1, typename T2>
void flip2(F f, T1 &&t1, T2 &&t2)
{
f(t2, t1);
}
void g(int &&i, int &j)
{
@Charles0429
Charles0429 / gist:bed283d6a20900b9789a
Created July 30, 2014 00:59
an automatically expandable buffer
#include "cstr.h"
cstr cstr_new_len(const char *str, int len)
{
cstr_internal *ci;
int size;
size = sizeof(cstr_internal) + len + 1;
if(str)
{
int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct timeval *timeout) {
int s, rv;
char _port[6]; /* strlen("65535"); */
struct addrinfo hints, *servinfo, *p;
int blocking = (c->flags & REDIS_BLOCK);
snprintf(_port, 6, "%d", port);
memset(&hints,0,sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;