diff --git a/src/python-codec.c b/src/python-codec.c index d94d9a6..ab81310 100644 --- a/src/python-codec.c +++ b/src/python-codec.c @@ -236,7 +236,7 @@ static PyObject *py_hdr_encode(PyObject *self, PyObject *args) { for (index=0; index < max_index;) { uint64_t value = get_entry(vsrc, index); ++index; - + /* max encodable value must fit in 63 bit */ if (value == 0) { int64_t zeros = 1; @@ -269,7 +269,7 @@ static PyObject *py_hdr_encode(PyObject *self, PyObject *args) { */ static PyObject *py_hdr_decode(PyObject *self, PyObject *args) { uint8_t *src; /* t#: read only character buffer */ - int src_len; /* its length */ + Py_ssize_t src_len; /* its length */ int read_index; /* i: start decoding from this offset, must be < src_len */ void *vdst; /* l: address of a counts array */ int max_index; /* i: number of entries in that array, must be > 0 */ @@ -380,7 +380,7 @@ static PyObject *py_hdr_add_array(PyObject *self, PyObject *args) { int max_index; /* i: entries from 0 to max_index-1 are added */ int word_size; /* i: size of each entry in bytes 2,4,8 */ uint64_t total_count = 0; - + if (!PyArg_ParseTuple(args, "llii", &vdst, &vsrc, &max_index, &word_size)) { return NULL; } diff --git a/src/python-codec.h b/src/python-codec.h index 50cded7..629d922 100644 --- a/src/python-codec.h +++ b/src/python-codec.h @@ -1,4 +1,6 @@ +/* see https://python.readthedocs.io/en/stable/c-api/arg.html#strings-and-buffers */ +#define PY_SSIZE_T_CLEAN #include "Python.h" static PyObject *py_hdr_encode(PyObject *self, PyObject *args); diff --git a/test/raphael.hlog b/test/raphael.hlog new file mode 100644 index 0000000..6969bf1 --- /dev/null +++ b/test/raphael.hlog @@ -0,0 +1,4 @@ +#[Histogram log format version 1.1] +#[StartTime: 1629447481.658 (seconds since epoch), Fri Aug 20 08:18:01 UTC 2021] +"StartTimestamp","Interval_Length","Interval_Max","Interval_Compressed_Histogram" +1629447418.475,63.182,189.792,HISTggAABHJ42u2az6tNURTH969z733P9dz3w+/nN3mRCGVATIykFKFMDJQfA2LCQAbKH+BXTA0MDIiZgQyV/AMGRBlImUiUgXrS/R5l1Wqtfc553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