| 512 | } |
| 513 | |
| 514 | raxNode *raxCompressNode(raxNode *n, unsigned char *s, size_t len, raxNode **child) { |
| 515 | /* Allocate the child to link to this node. */ |
| 516 | *child = raxNewNode(0,0); |
| 517 | if (*child == NULL) return NULL; |
| 518 | |
| 519 | raxNode *newn = raxCompressNodeNoAlloc(n,s,len); |
| 520 | if (newn == NULL) { |
| 521 | rax_free(*child); |
| 522 | return NULL; |
| 523 | } |
| 524 | n = newn; |
| 525 | raxNode **childfield = raxNodeLastChildPtr(n); |
| 526 | memcpy(childfield,child,sizeof(*child)); |
| 527 | return n; |
| 528 | } |
| 529 | |
| 530 | /* Low level function that walks the tree looking for the string |
| 531 | * 's' of 'len' bytes. The function returns the number of characters |
no test coverage detected