MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / bin_extend

Function bin_extend

bin_interface.c:507–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

505}
506
507static 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
534void bin_free_packet(bin_packet_t *packet)
535{

Callers 3

bin_append_bufferFunction · 0.85
bin_push_strFunction · 0.85
bin_push_intFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected