aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface/src/misc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/erl_interface/src/misc')
-rw-r--r--lib/erl_interface/src/misc/ei_printterm.c14
-rw-r--r--lib/erl_interface/src/misc/ei_x_encode.c6
-rw-r--r--lib/erl_interface/src/misc/show_msg.c9
3 files changed, 11 insertions, 18 deletions
diff --git a/lib/erl_interface/src/misc/ei_printterm.c b/lib/erl_interface/src/misc/ei_printterm.c
index a89b990ac1..5c40fb7747 100644
--- a/lib/erl_interface/src/misc/ei_printterm.c
+++ b/lib/erl_interface/src/misc/ei_printterm.c
@@ -250,12 +250,13 @@ static int print_term(FILE* fp, ei_x_buff* x,
ei_free(p);
break;
case ERL_BIT_BINARY_EXT: {
+ const char* cp;
size_t bits;
+ unsigned int bitoffs;
int trunc = 0;
- p = ei_malloc(n);
- if (p == NULL) goto err;
- if (ei_decode_bitstring(buf, index, p, n, &bits) < 0) {
- ei_free(p);
+
+ if (ei_decode_bitstring(buf, index, &cp, &bitoffs, &bits) < 0
+ || bitoffs != 0) {
goto err;
}
ch_written += xprintf(fp, x, "#Bits<");
@@ -266,15 +267,14 @@ static int print_term(FILE* fp, ei_x_buff* x,
}
--m;
for (i = 0; i < m; ++i) {
- ch_written += xprintf(fp, x, "%d,", p[i]);
+ ch_written += xprintf(fp, x, "%d,", cp[i]);
}
- ch_written += xprintf(fp, x, "%d", p[i]);
+ ch_written += xprintf(fp, x, "%d", cp[i]);
if (trunc)
ch_written += xprintf(fp, x, ",...");
else if (bits % 8 != 0)
ch_written += xprintf(fp, x, ":%u", (unsigned)(bits % 8));
xputc('>', fp, x); ++ch_written;
- ei_free(p);
break;
}
case ERL_SMALL_INTEGER_EXT:
diff --git a/lib/erl_interface/src/misc/ei_x_encode.c b/lib/erl_interface/src/misc/ei_x_encode.c
index 2da271795f..8e77679d2a 100644
--- a/lib/erl_interface/src/misc/ei_x_encode.c
+++ b/lib/erl_interface/src/misc/ei_x_encode.c
@@ -117,14 +117,14 @@ int ei_x_encode_binary(ei_x_buff* x, const void* p, int len)
return ei_encode_binary(x->buff, &x->index, p, len);
}
-int ei_x_encode_bitstring(ei_x_buff* x, const void* p, size_t bits)
+int ei_x_encode_bitstring(ei_x_buff* x, const char* p, size_t bitoffs, size_t bits)
{
int i = x->index;
- if (ei_encode_bitstring(NULL, &i, p, bits) == -1)
+ if (ei_encode_bitstring(NULL, &i, p, bitoffs, bits) == -1)
return -1;
if (!x_fix_buff(x, i))
return -1;
- return ei_encode_bitstring(x->buff, &x->index, p, bits);
+ return ei_encode_bitstring(x->buff, &x->index, p, bitoffs, bits);
}
int ei_x_encode_long(ei_x_buff* x, long n)
diff --git a/lib/erl_interface/src/misc/show_msg.c b/lib/erl_interface/src/misc/show_msg.c
index 2d49eb6449..805d69e9b3 100644
--- a/lib/erl_interface/src/misc/show_msg.c
+++ b/lib/erl_interface/src/misc/show_msg.c
@@ -24,13 +24,6 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-
-#ifndef SIZE_MAX
-# define SIZE_MAX (~((size_t)0))
-#endif
#include <sys/types.h>
@@ -464,7 +457,7 @@ static void show_term(const char *termbuf, int *index, FILE *stream)
case ERL_BIT_BINARY_EXT: {
size_t bits;
- ei_decode_bitstring(termbuf, index, NULL, SIZE_MAX, &bits);
+ ei_decode_bitstring(termbuf, index, NULL, NULL, &bits);
fprintf(stream, "#Bits<%lu>", (unsigned long)bits);
break;
}