| 505 | } |
| 506 | |
| 507 | static int bin_extend(bin_packet_t *packet, int size) |
| 508 | { |
| 509 | int required; |
| 510 | |
| 511 | if (size < 0 || packet->buffer.len + size > BIN_MAX_BUF_LEN) { |
| 512 | LM_ERR("cannot make the buffer bigger\n"); |
| 513 | return -1; |
| 514 | } |
| 515 | |
| 516 | required = packet->buffer.len + size; |
| 517 | |
| 518 | if (2 * required > BIN_MAX_BUF_LEN) |
| 519 | packet->size = BIN_MAX_BUF_LEN; |
| 520 | else |
| 521 | packet->size = 2 * required; |
| 522 | |
| 523 | packet->buffer.s = (packet->flags & BINFL_SYSMEM) ? |
| 524 | realloc(packet->buffer.s, packet->size) : |
| 525 | pkg_realloc(packet->buffer.s, packet->size); |
| 526 | if (!packet->buffer.s) { |
| 527 | LM_ERR("pkg realloc failed\n"); |
| 528 | return -1; |
| 529 | } |
| 530 | |
| 531 | return 0; |
| 532 | } |
| 533 | |
| 534 | void bin_free_packet(bin_packet_t *packet) |
| 535 | { |
no outgoing calls
no test coverage detected