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