Bytes needed to store an integer of given serial type
| 254 | |
| 255 | // Bytes needed to store an integer of given serial type |
| 256 | static int int_storage_bytes(int serial_type) { |
| 257 | switch (serial_type) { |
| 258 | case 0: |
| 259 | return 0; // NULL |
| 260 | case SERIAL_INT8: |
| 261 | return SERIAL_SIZE_INT8; |
| 262 | case SERIAL_INT16: |
| 263 | return SERIAL_SIZE_INT16; |
| 264 | case SERIAL_INT24: |
| 265 | return SERIAL_SIZE_INT24; |
| 266 | case SERIAL_INT32: |
| 267 | return SERIAL_SIZE_INT32; |
| 268 | case SERIAL_INT48: |
| 269 | return SERIAL_SIZE_INT48; |
| 270 | case SERIAL_INT64: |
| 271 | return SERIAL_SIZE_INT64; |
| 272 | case SERIAL_CONST_ZERO: // integer 0 |
| 273 | case SERIAL_CONST_ONE: // integer 1 |
| 274 | default: |
| 275 | return 0; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | // Write integer in big-endian for given byte count |
| 280 | static void put_int_be(uint8_t *buf, int64_t val, int nbytes) { |