static size_t memdup(char **dst, void *src, size_t len) { if(len) *dst = malloc(len); else *dst = 0; if(!*dst) return 0; memcpy(*dst, src, len); return len; } _xcb_map* _xcb_map_new(){ _xcb_map* list; list = malloc(sizeof(_xcb_map)); if(!list) return 0; list->head = 0; list->tail = &list->head; return list; }