Create a new consumer group in the context of the stream 's', having the * specified name and last server ID. If a consumer group with the same name * already existed NULL is returned, otherwise the pointer to the consumer * group is returned. */
| 2267 | * already existed NULL is returned, otherwise the pointer to the consumer |
| 2268 | * group is returned. */ |
| 2269 | streamCG *streamCreateCG(stream *s, char *name, size_t namelen, streamID *id) { |
| 2270 | if (s->cgroups == NULL) s->cgroups = raxNew(); |
| 2271 | if (raxFind(s->cgroups,(unsigned char*)name,namelen) != raxNotFound) |
| 2272 | return NULL; |
| 2273 | |
| 2274 | streamCG *cg = (streamCG*)zmalloc(sizeof(*cg), MALLOC_SHARED); |
| 2275 | cg->pel = raxNew(); |
| 2276 | cg->consumers = raxNew(); |
| 2277 | cg->last_id = *id; |
| 2278 | raxInsert(s->cgroups,(unsigned char*)name,namelen,cg,NULL); |
| 2279 | return cg; |
| 2280 | } |
| 2281 | |
| 2282 | /* Free a consumer group and all its associated data. */ |
| 2283 | void streamFreeCG(streamCG *cg) { |
no test coverage detected