💾 Archived View for gmi.noulin.net › gitRepositories › netSerial › file › netSerial.c.gcov.gmi captured on 2024-09-29 at 01:15:12. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

netSerial

Log

Files

Refs

README

LICENSE

netSerial.c.gcov (297007B)

     1         -:    0:Source:/home/remy/git/sw/publicGits/netSerial/netSerial.c
     2         -:    0:Graph:netSerial.gcno
     3         -:    0:Data:netSerial.gcda
     4         -:    0:Runs:7
     5         -:    0:Programs:1
     6         -:    1:
     7         -:    2:#include "libsheepyObject.h"
     8         -:    3:#include "netSerial.h"
     9         -:    4:#include "netSerialInternal.h"
    10         -:    5:
    11         -:    6:#include <stdlib.h>
    12         -:    7:#include <string.h>
    13         -:    8:#include <stdio.h>
    14         -:    9:
    15         -:   10:#define lv logVarG
    16         -:   11:
    17         -:   12:void initiateNetSerialLevel0(smallJsont *self);
    18         -:   13:void initiateNetSerialLevel1(smallJsont *self);
    19         -:   14:void initiateNetSerialLevel2(smallJsont *self);
    20         -:   15:void initiateNetSerial(smallJsont *self);
    21         -:   16:void registerMethodsNetSerialLevel0(smallJsonFunctionst *f);
    22         -:   17:void registerMethodsNetSerialLevel1(smallJsonFunctionst *f);
    23         -:   18:void registerMethodsNetSerialLevel2(smallJsonFunctionst *f);
    24         -:   19:void registerMethodsNetSerial(smallJsonFunctionst *f);
    25         -:   20:void initiateAllocateNetSerialLevel0(smallJsont **self);
    26         -:   21:void initiateAllocateNetSerialLevel1(smallJsont **self);
    27         -:   22:void initiateAllocateNetSerialLevel2(smallJsont **self);
    28         -:   23:void initiateAllocateNetSerial(smallJsont **self);
    29         -:   24:void finalizeNetSerial(void);
    30         -:   25:smallJsont* allocNetSerialLevel0(void);
    31         -:   26:smallJsont* allocNetSerialLevel1(void);
    32         -:   27:smallJsont* allocNetSerialLevel2(void);
    33         -:   28:smallJsont* allocNetSerial(void);
    34         -:   29:internal const char* helpNetSerial(smallJsont *self);
    35         -:   30:internal smallBytest* serialNetSerialLevel0(smallJsont *self);
    36         -:   31:internal smallBytest* serialNetSerialLevel1(smallJsont *self);
    37         -:   32:internal smallBytest* serialNetSerialLevel2(smallJsont *self);
    38         -:   33:internal smallBytest* serialNetSerial(smallJsont *self);
    39         -:   34:internal smallJsont* deserialNetSerialLevel0(smallJsont *self, smallBytest *data);
    40         -:   35:internal smallJsont* deserialNetSerialLevel1(smallJsont *self, smallBytest *data);
    41         -:   36:internal smallJsont* deserialNetSerialLevel2(smallJsont *self, smallBytest *data);
    42         -:   37:internal smallJsont* deserialNetSerial(smallJsont *self, smallBytest *data);
    43         -:   38:
    44         -:   39:internal void uintToNetTypeVarint(sBytest **buf, u8 type, u64 value);
    45         -:   40:internal void uintToVarint(sBytest **buf, u64 value);
    46         -:   41:internal u64 netTypeVarintToUint(u8 **buf);
    47         -:   42:internal u64 varintToUint(u8 **buf);
    48         -:   43:
    49         -:   44:internal sBytest* netSerialLevel0(smallt *o);
    50         -:   45:internal void dictNetSerialLevel0(sBytest **r, sDictt *dict);
    51         -:   46:internal void arrayNetSerialLevel0(sBytest **r, sArrayt *array);
    52         -:   47:internal sBytest* netSerialLevel1(smallt *o);
    53         -:   48:internal void dictNetSerialLevel1(sBytest **r, sDictt *dict, contextt *ctx);
    54         -:   49:internal void arrayNetSerialLevel1(sBytest **r, sArrayt *array, contextt *ctx);
    55         -:   50:internal sBytest* netSerialLevel2(smallt *o);
    56         -:   51:internal void dictNetSerialLevel2(sBytest **r, sDictt *dict, contextt *ctx, bool packed);
    57         -:   52:internal void arrayNetSerialLevel2(sBytest **r, sArrayt *array, contextt *ctx, bool packed);
    58         -:   53:internal sBytest* netSerial(smallt *o);
    59         -:   54:internal void dictNetSerial(sBytest **r, sDictt *dict, contextt *ctx, packingT packing);
    60         -:   55:internal void arrayNetSerial(sBytest **r, sArrayt *array, contextt *ctx, packingT packing);
    61         -:   56:
    62         -:   57:internal smallt* netDeserialLevel0(sBytest *obj);
    63         -:   58:internal void dictNetDeserialLevel0(sDictt **dict, char **data);
    64         -:   59:internal void arrayNetDeserialLevel0(sArrayt **array, char **data);
    65         -:   60:internal smallt* netDeserialLevel1(sBytest *obj);
    66         -:   61:internal void dictNetDeserialLevel1(sDictt **dict, u8 **data, contextt *ctx);
    67         -:   62:internal void arrayNetDeserialLevel1(sArrayt **array, u8 **data, contextt *ctx);
    68         -:   63:internal smallt* netDeserialLevel2(sBytest *obj);
    69         -:   64:internal void dictNetDeserialLevel2(sDictt **dict, u8 **data, contextt *ctx, bool packed);
    70         -:   65:internal u8 isDictUniform(sDictt *dict);
    71         -:   66:internal u8 isArrayUniform(sArrayt *array);
    72         -:   67:internal void uniformDictNetDeserialLevel2(sDictt **dict, u8 **data, contextt *ctx, bool packed);
    73         -:   68:internal void arrayNetDeserialLevel2(sArrayt **array, u8 **data, contextt *ctx, bool packed);
    74         -:   69:internal void uniformArrayNetDeserialLevel2(sArrayt **array, u8 **data, contextt *ctx, bool packed);
    75         -:   70:internal smallt* netDeserial(sBytest *obj);
    76         -:   71:internal void dictNetDeserial(sDictt **dict, u8 **data, contextt *ctx, bool packed);
    77         -:   72:internal void uniformDictNetDeserial(sDictt **dict, u8 **data, contextt *ctx, bool packed);
    78         -:   73:internal void arrayNetDeserial(sArrayt **array, u8 **data, contextt *ctx, bool packed);
    79         -:   74:internal void uniformArrayNetDeserial(sArrayt **array, u8 **data, contextt *ctx, bool packed);
    80         -:   75:
    81         -:   76:/* enable/disable logging */
    82         -:   77:/* #undef pLog */
    83         -:   78:/* #define pLog(...) */
    84         -:   79:
    85 function initiateNetSerialLevel0 called 0 returned 0% blocks executed 0%
    86     #####:   80:void initiateNetSerialLevel0(smallJsont *self) {
    87         -:   81:
    88     #####:   82:  initiateSmallJson(self);
    89 call    0 never executed
    90         -:   83:
    91     #####:   84:  self->type = "netSerial";
    92     #####:   85:  if (!netSerialF) {
    93 branch  0 never executed
    94 branch  1 never executed
    95     #####:   86:    netSerialF            = malloc(sizeof(smallJsonFunctionst));
    96     #####:   87:    registerMethodsNetSerialLevel0(netSerialF);
    97 call    0 never executed
    98     #####:   88:    pErrorNot0(atexit(finalizeNetSerial));
    99 call    0 never executed
   100 branch  1 never executed
   101 branch  2 never executed
   102 branch  3 never executed
   103 branch  4 never executed
   104 call    5 never executed
   105 branch  6 never executed
   106 branch  7 never executed
   107 call    8 never executed
   108 branch  9 never executed
   109 branch 10 never executed
   110 call   11 never executed
   111 call   12 never executed
   112 call   13 never executed
   113 call   14 never executed
   114         -:   89:  }
   115     #####:   90:  self->f = netSerialF;
   116     #####:   91:}
   117         -:   92:
   118 function initiateNetSerialLevel1 called 0 returned 0% blocks executed 0%
   119     #####:   93:void initiateNetSerialLevel1(smallJsont *self) {
   120         -:   94:
   121     #####:   95:  initiateSmallJson(self);
   122 call    0 never executed
   123         -:   96:
   124     #####:   97:  self->type = "netSerial";
   125     #####:   98:  if (!netSerialF) {
   126 branch  0 never executed
   127 branch  1 never executed
   128     #####:   99:    netSerialF            = malloc(sizeof(smallJsonFunctionst));
   129     #####:  100:    registerMethodsNetSerialLevel1(netSerialF);
   130 call    0 never executed
   131     #####:  101:    pErrorNot0(atexit(finalizeNetSerial));
   132 call    0 never executed
   133 branch  1 never executed
   134 branch  2 never executed
   135 branch  3 never executed
   136 branch  4 never executed
   137 call    5 never executed
   138 branch  6 never executed
   139 branch  7 never executed
   140 call    8 never executed
   141 branch  9 never executed
   142 branch 10 never executed
   143 call   11 never executed
   144 call   12 never executed
   145 call   13 never executed
   146 call   14 never executed
   147         -:  102:  }
   148     #####:  103:  self->f = netSerialF;
   149     #####:  104:}
   150         -:  105:
   151 function initiateNetSerialLevel2 called 0 returned 0% blocks executed 0%
   152     #####:  106:void initiateNetSerialLevel2(smallJsont *self) {
   153         -:  107:
   154     #####:  108:  initiateSmallJson(self);
   155 call    0 never executed
   156         -:  109:
   157     #####:  110:  self->type = "netSerial";
   158     #####:  111:  if (!netSerialF) {
   159 branch  0 never executed
   160 branch  1 never executed
   161     #####:  112:    netSerialF            = malloc(sizeof(smallJsonFunctionst));
   162     #####:  113:    registerMethodsNetSerialLevel2(netSerialF);
   163 call    0 never executed
   164     #####:  114:    pErrorNot0(atexit(finalizeNetSerial));
   165 call    0 never executed
   166 branch  1 never executed
   167 branch  2 never executed
   168 branch  3 never executed
   169 branch  4 never executed
   170 call    5 never executed
   171 branch  6 never executed
   172 branch  7 never executed
   173 call    8 never executed
   174 branch  9 never executed
   175 branch 10 never executed
   176 call   11 never executed
   177 call   12 never executed
   178 call   13 never executed
   179 call   14 never executed
   180         -:  115:  }
   181     #####:  116:  self->f = netSerialF;
   182     #####:  117:}
   183         -:  118:
   184 function initiateNetSerial called 12 returned 100% blocks executed 40%
   185        12:  119:void initiateNetSerial(smallJsont *self) {
   186         -:  120:
   187        12:  121:  initiateSmallJson(self);
   188 call    0 returned 100%
   189         -:  122:
   190        12:  123:  self->type = "netSerial";
   191        12:  124:  if (!netSerialF) {
   192 branch  0 taken 50% (fallthrough)
   193 branch  1 taken 50%
   194         6:  125:    netSerialF            = malloc(sizeof(smallJsonFunctionst));
   195         6:  126:    registerMethodsNetSerial(netSerialF);
   196 call    0 returned 100%
   197         6:  127:    pErrorNot0(atexit(finalizeNetSerial));
   198 call    0 returned 100%
   199 branch  1 taken 0% (fallthrough)
   200 branch  2 taken 100%
   201 branch  3 never executed
   202 branch  4 never executed
   203 call    5 never executed
   204 branch  6 never executed
   205 branch  7 never executed
   206 call    8 never executed
   207 branch  9 never executed
   208 branch 10 never executed
   209 call   11 never executed
   210 call   12 never executed
   211 call   13 never executed
   212 call   14 never executed
   213         -:  128:  }
   214        12:  129:  self->f = netSerialF;
   215        12:  130:}
   216         -:  131:
   217 function registerMethodsNetSerialLevel0 called 0 returned 0% blocks executed 0%
   218     #####:  132:void registerMethodsNetSerialLevel0(smallJsonFunctionst *f) {
   219         -:  133:
   220     #####:  134:  registerMethodsSmallJson(f);
   221 call    0 never executed
   222     #####:  135:  f->help      = helpNetSerial;
   223     #####:  136:  f->serial    = serialNetSerialLevel0;
   224     #####:  137:  f->deserial  = deserialNetSerialLevel0;
   225     #####:  138:}
   226         -:  139:
   227 function registerMethodsNetSerialLevel1 called 0 returned 0% blocks executed 0%
   228     #####:  140:void registerMethodsNetSerialLevel1(smallJsonFunctionst *f) {
   229         -:  141:
   230     #####:  142:  registerMethodsSmallJson(f);
   231 call    0 never executed
   232     #####:  143:  f->help      = helpNetSerial;
   233     #####:  144:  f->serial    = serialNetSerialLevel1;
   234     #####:  145:  f->deserial  = deserialNetSerialLevel1;
   235     #####:  146:}
   236         -:  147:
   237 function registerMethodsNetSerialLevel2 called 0 returned 0% blocks executed 0%
   238     #####:  148:void registerMethodsNetSerialLevel2(smallJsonFunctionst *f) {
   239         -:  149:
   240     #####:  150:  registerMethodsSmallJson(f);
   241 call    0 never executed
   242     #####:  151:  f->help      = helpNetSerial;
   243     #####:  152:  f->serial    = serialNetSerialLevel2;
   244     #####:  153:  f->deserial  = deserialNetSerialLevel2;
   245     #####:  154:}
   246         -:  155:
   247 function registerMethodsNetSerial called 6 returned 100% blocks executed 100%
   248         6:  156:void registerMethodsNetSerial(smallJsonFunctionst *f) {
   249         -:  157:
   250         6:  158:  registerMethodsSmallJson(f);
   251 call    0 returned 100%
   252         6:  159:  f->help      = helpNetSerial;
   253         6:  160:  f->serial    = serialNetSerial;
   254         6:  161:  f->deserial  = deserialNetSerial;
   255         6:  162:}
   256         -:  163:
   257 function initiateAllocateNetSerialLevel0 called 0 returned 0% blocks executed 0%
   258     #####:  164:void initiateAllocateNetSerialLevel0(smallJsont **self) {
   259         -:  165:
   260     #####:  166:  if (self) {
   261 branch  0 never executed
   262 branch  1 never executed
   263     #####:  167:    initiateG(self); // call initiateAllocateSmallJson to initialize the container recycling system
   264 call    0 never executed
   265     #####:  168:    if (*self) {
   266 branch  0 never executed
   267 branch  1 never executed
   268     #####:  169:      initiateNetSerialLevel0(*self);
   269 call    0 never executed
   270         -:  170:    }
   271         -:  171:  }
   272     #####:  172:}
   273         -:  173:
   274 function initiateAllocateNetSerialLevel1 called 0 returned 0% blocks executed 0%
   275     #####:  174:void initiateAllocateNetSerialLevel1(smallJsont **self) {
   276         -:  175:
   277     #####:  176:  if (self) {
   278 branch  0 never executed
   279 branch  1 never executed
   280     #####:  177:    initiateG(self); // call initiateAllocateSmallJson to initialize the container recycling system
   281 call    0 never executed
   282     #####:  178:    if (*self) {
   283 branch  0 never executed
   284 branch  1 never executed
   285     #####:  179:      initiateNetSerialLevel1(*self);
   286 call    0 never executed
   287         -:  180:    }
   288         -:  181:  }
   289     #####:  182:}
   290         -:  183:
   291 function initiateAllocateNetSerialLevel2 called 0 returned 0% blocks executed 0%
   292     #####:  184:void initiateAllocateNetSerialLevel2(smallJsont **self) {
   293         -:  185:
   294     #####:  186:  if (self) {
   295 branch  0 never executed
   296 branch  1 never executed
   297     #####:  187:    initiateG(self); // call initiateAllocateSmallJson to initialize the container recycling system
   298 call    0 never executed
   299     #####:  188:    if (*self) {
   300 branch  0 never executed
   301 branch  1 never executed
   302     #####:  189:      initiateNetSerialLevel2(*self);
   303 call    0 never executed
   304         -:  190:    }
   305         -:  191:  }
   306     #####:  192:}
   307         -:  193:
   308 function initiateAllocateNetSerial called 0 returned 0% blocks executed 0%
   309     #####:  194:void initiateAllocateNetSerial(smallJsont **self) {
   310         -:  195:
   311     #####:  196:  if (self) {
   312 branch  0 never executed
   313 branch  1 never executed
   314     #####:  197:    initiateG(self); // call initiateAllocateSmallJson to initialize the container recycling system
   315 call    0 never executed
   316     #####:  198:    if (*self) {
   317 branch  0 never executed
   318 branch  1 never executed
   319     #####:  199:      initiateNetSerial(*self);
   320 call    0 never executed
   321         -:  200:    }
   322         -:  201:  }
   323     #####:  202:}
   324         -:  203:
   325 function finalizeNetSerial called 6 returned 100% blocks executed 100%
   326         6:  204:void finalizeNetSerial(void) {
   327         -:  205:
   328         6:  206:  if (netSerialF) {
   329 branch  0 taken 100% (fallthrough)
   330 branch  1 taken 0%
   331         6:  207:    free(netSerialF);
   332         6:  208:    netSerialF = NULL;
   333         -:  209:  }
   334         6:  210:}
   335         -:  211:
   336 function allocNetSerialLevel0 called 0 returned 0% blocks executed 0%
   337     #####:  212:smallJsont* allocNetSerialLevel0(void) {
   338     #####:  213:  smallJsont *r = NULL;
   339         -:  214:
   340     #####:  215:  initiateAllocateNetSerialLevel0(&r);
   341 call    0 never executed
   342     #####:  216:  ret r;
   343         -:  217:}
   344         -:  218:
   345 function allocNetSerialLevel1 called 0 returned 0% blocks executed 0%
   346     #####:  219:smallJsont* allocNetSerialLevel1(void) {
   347     #####:  220:  smallJsont *r = NULL;
   348         -:  221:
   349     #####:  222:  initiateAllocateNetSerialLevel1(&r);
   350 call    0 never executed
   351     #####:  223:  ret r;
   352         -:  224:}
   353         -:  225:
   354 function allocNetSerialLevel2 called 0 returned 0% blocks executed 0%
   355     #####:  226:smallJsont* allocNetSerialLevel2(void) {
   356     #####:  227:  smallJsont *r = NULL;
   357         -:  228:
   358     #####:  229:  initiateAllocateNetSerialLevel2(&r);
   359 call    0 never executed
   360     #####:  230:  ret r;
   361         -:  231:}
   362         -:  232:
   363 function allocNetSerial called 0 returned 0% blocks executed 0%
   364     #####:  233:smallJsont* allocNetSerial(void) {
   365     #####:  234:  smallJsont *r = NULL;
   366         -:  235:
   367     #####:  236:  initiateAllocateNetSerial(&r);
   368 call    0 never executed
   369     #####:  237:  ret r;
   370         -:  238:}
   371         -:  239:
   372         -:  240:
   373 function helpNetSerial called 0 returned 0% blocks executed 0%
   374     #####:  241:internal const char* helpNetSerial(smallJsont UNUSED *self) {
   375     #####:  242:  ret "TODO helpNetSerial \n" helpTextSmallJson;
   376         -:  243:}
   377         -:  244:
   378         -:  245:/**
   379         -:  246: * encode type in lower nibble, uint value in high nibble and next bytes as varuint
   380         -:  247: */
   381 function uintToNetTypeVarint called 120 returned 100% blocks executed 100%
   382       120:  248:internal void uintToNetTypeVarint(sBytest **buf, u8 type, u64 value) {
   383       120:  249:  u64 c = value;
   384         -:  250:  /* encode b0..2 */
   385       120:  251:  u8  b = type + ((c & 0x7) << 4);
   386       120:  252:  if (c & 0xFFFFFFFFFFFFFFF8) {
   387 branch  0 taken 10% (fallthrough)
   388 branch  1 taken 90%
   389        12:  253:    b |= 0x80;
   390        12:  254:    sBytesPush(buf, b);
   391 call    0 returned 100%
   392        12:  255:    c >>=3;
   393         -:  256:    /* encode b3..9 ...*/
   394        49:  257:    while(c) {
   395 branch  0 taken 68%
   396 branch  1 taken 32%
   397        25:  258:      b = c & 0x7F;
   398        25:  259:      if (c & 0xFFFFFFFFFFFFFF80)
   399 branch  0 taken 52% (fallthrough)
   400 branch  1 taken 48%
   401        13:  260:        b |= 0x80;
   402        25:  261:      sBytesPush(buf, b);
   403 call    0 returned 100%
   404        25:  262:      c >>=7;
   405         -:  263:    }
   406         -:  264:  }
   407         -:  265:  else
   408       108:  266:    sBytesPush(buf, b);
   409 call    0 returned 100%
   410       120:  267:}
   411         -:  268:
   412         -:  269:/**
   413         -:  270: * encode uint as varuint
   414         -:  271: */
   415 function uintToVarint called 191 returned 100% blocks executed 90%
   416       191:  272:internal void uintToVarint(sBytest **buf, u64 value) {
   417       191:  273:  u64 c = value;
   418       191:  274:  u8  b = c & 0x7F;
   419       191:  275:  if (c & 0xFFFFFFFFFFFFFF80) {
   420 branch  0 taken 2% (fallthrough)
   421 branch  1 taken 98%
   422         3:  276:    b |= 0x80;
   423         3:  277:    sBytesPush(buf, b);
   424 call    0 returned 100%
   425         3:  278:    c >>=7;
   426         -:  279:    /* encode b7..14 ...*/
   427         9:  280:    while(c) {
   428 branch  0 taken 50%
   429 branch  1 taken 50%
   430         3:  281:      b = c & 0x7F;
   431         3:  282:      if (c & 0xFFFFFFFFFFFFFF80)
   432 branch  0 taken 0% (fallthrough)
   433 branch  1 taken 100%
   434     #####:  283:        b |= 0x80;
   435         3:  284:      sBytesPush(buf, b);
   436 call    0 returned 100%
   437         3:  285:      c >>=7;
   438         -:  286:    }
   439         -:  287:  }
   440         -:  288:  else
   441       188:  289:    sBytesPush(buf, b);
   442 call    0 returned 100%
   443       191:  290:}
   444         -:  291:
   445         -:  292:/**
   446         -:  293: * decode type and varuint to uint
   447         -:  294: */
   448 function netTypeVarintToUint called 120 returned 100% blocks executed 100%
   449       120:  295:internal u64 netTypeVarintToUint(u8 **buf) {
   450       120:  296:  u64 r = 0;
   451         -:  297:
   452       120:  298:  r = (**buf >> 4) & 0x7;
   453         -:  299:
   454       120:  300:  u8 c = 0;
   455       265:  301:  while (**buf & 0x80) {
   456 branch  0 taken 17%
   457 branch  1 taken 83% (fallthrough)
   458        25:  302:    (*buf)++;
   459         -:  303:    // note: keep 0x7FUL to use 64 bit shift operation, without UL a 32 bit shift operation is use and then casted to 64 bit
   460        25:  304:    r |= (**buf & 0x7FUL) << (7*c+3);
   461        25:  305:    c++;
   462         -:  306:  }
   463       120:  307:  (*buf)++;
   464       120:  308:  ret r;
   465         -:  309:}
   466         -:  310:
   467         -:  311:/**
   468         -:  312: * decode varuint to uint
   469         -:  313: */
   470 function varintToUint called 191 returned 100% blocks executed 100%
   471       191:  314:internal u64 varintToUint(u8 **buf) {
   472       191:  315:  u64 r = 0;
   473         -:  316:
   474       191:  317:  r = (**buf) & 0x7F;
   475       191:  318:  u8 c = 1;
   476       385:  319:  while (**buf & 0x80) {
   477 branch  0 taken 2%
   478 branch  1 taken 98% (fallthrough)
   479         3:  320:    (*buf)++;
   480         -:  321:    // note: keep 0x7FUL to use 64 bit shift operation, without UL a 32 bit shift operation is use and then casted to 64 bit
   481         3:  322:    r |= (**buf & 0x7FUL) << (7*c);
   482         3:  323:    c++;
   483         -:  324:  }
   484       191:  325:  (*buf)++;
   485       191:  326:  ret r;
   486         -:  327:}
   487         -:  328:
   488         -:  329:// -------------------------------------
   489         -:  330:// Serializers
   490         -:  331:
   491         -:  332:// level 0
   492         -:  333:// like smallJson with ints and length encoded as varints
   493         -:  334:
   494         -:  335:/**
   495         -:  336: * serializer top function
   496         -:  337: */
   497 function netSerialLevel0 called 0 returned 0% blocks executed 0%
   498     #####:  338:internal sBytest* netSerialLevel0(smallt *o) {
   499     #####:  339:  sBytest *r = NULL;
   500     #####:  340:  sBytest *B = NULL;
   501         -:  341:
   502     #####:  342:  switch(o->type) {
   503 branch  0 never executed
   504 branch  1 never executed
   505 branch  2 never executed
   506 branch  3 never executed
   507 branch  4 never executed
   508 branch  5 never executed
   509 branch  6 never executed
   510 branch  7 never executed
   511 branch  8 never executed
   512 branch  9 never executed
   513         -:  343:    case UNDEFINED:
   514     #####:  344:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
   515 call    0 never executed
   516     #####:  345:      break;
   517         -:  346:    case BOOL: {
   518     #####:  347:      u8 c = NET_SERIAL_TYPES[(u8)o->type];
   519         -:  348:      // set bit 4 when true
   520     #####:  349:      if (((sBoolt *)&(o->type))->value)
   521 branch  0 never executed
   522 branch  1 never executed
   523     #####:  350:        c |= (1<<4);
   524     #####:  351:      sBytesPush(&r, c);
   525 call    0 never executed
   526         -:  352:      }
   527     #####:  353:      break;
   528         -:  354:    case CONTAINER:
   529         -:  355:      // undefined
   530     #####:  356:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
   531 call    0 never executed
   532     #####:  357:      break;
   533         -:  358:    case DICT:
   534     #####:  359:      dictNetSerialLevel0(&r, (sDictt *)&(o->type));
   535 call    0 never executed
   536     #####:  360:      break;
   537         -:  361:    case DOUBLE:
   538     #####:  362:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
   539 call    0 never executed
   540     #####:  363:      sBytesPushBuffer(&r, &((sDoublet *)&(o->type))->value, sizeof(double));
   541 call    0 never executed
   542     #####:  364:      break;
   543         -:  365:    case INT: {
   544         -:  366:      // encode int to varint
   545         -:  367:      // v is int64_t to convert to varint
   546     #####:  368:      i64 v = ((sIntt *)&(o->type))->value;
   547         -:  369:      // encode v with arithmetic shifts
   548     #####:  370:      uintToNetTypeVarint(&r, NET_SERIAL_TYPES[(u8)o->type], (v << 1) ^ (v >> 63));
   549 call    0 never executed
   550         -:  371:      }
   551     #####:  372:      break;
   552         -:  373:    case STRING:
   553     #####:  374:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
   554 call    0 never executed
   555     #####:  375:      sBytesPushBuffer(&r, &((sStringt *)&(o->type))->data, sizeof(sStringt) + strlen(&(((sStringt *)&(o->type))->data)) -1);
   556 call    0 never executed
   557     #####:  376:      break;
   558         -:  377:    case ARRAY:
   559     #####:  378:      arrayNetSerialLevel0(&r, (sArrayt *)&(o->type));
   560 call    0 never executed
   561     #####:  379:      break;
   562         -:  380:    case BYTES:
   563     #####:  381:      B = (sBytest *)&(o->type);
   564     #####:  382:      uintToNetTypeVarint(&r, NET_SERIAL_TYPES[(u8)o->type], B->count);
   565 call    0 never executed
   566     #####:  383:      sBytesPushBuffer(&r, &(B->data), B->count);
   567 call    0 never executed
   568     #####:  384:      break;
   569         -:  385:  }
   570     #####:  386:  ret r;
   571         -:  387:}
   572         -:  388:
   573         -:  389:/**
   574         -:  390: * serialize dictionary
   575         -:  391: *
   576         -:  392: * the serialized dict is pushed to r.
   577         -:  393: * All elements are serialized recursively
   578         -:  394: *
   579         -:  395: * the data in containers is not serialized
   580         -:  396: *
   581         -:  397: * \param
   582         -:  398: *   r small bytes object
   583         -:  399: *   dict dictionary to serialize
   584         -:  400: */
   585 function dictNetSerialLevel0 called 0 returned 0% blocks executed 0%
   586     #####:  401:internal void dictNetSerialLevel0(sBytest **r, sDictt *dict) {
   587     #####:  402:  sBytest *B = NULL;
   588         -:  403:
   589     #####:  404:  uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)dict->type], dict->count);
   590 call    0 never executed
   591         -:  405:
   592     #####:  406:  forEachSDict(dict, e) {
   593 branch  0 never executed
   594 branch  1 never executed
   595     #####:  407:    if (e->key) {
   596 branch  0 never executed
   597 branch  1 never executed
   598     #####:  408:      sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
   599 call    0 never executed
   600         -:  409:
   601     #####:  410:      switch(e->data->type) {
   602 branch  0 never executed
   603 branch  1 never executed
   604 branch  2 never executed
   605 branch  3 never executed
   606 branch  4 never executed
   607 branch  5 never executed
   608 branch  6 never executed
   609 branch  7 never executed
   610 branch  8 never executed
   611 branch  9 never executed
   612         -:  411:        case UNDEFINED:
   613     #####:  412:          sBytesPush(r, NET_SERIAL_TYPES[(u8)e->data->type]);
   614 call    0 never executed
   615     #####:  413:          break;
   616         -:  414:        case BOOL: {
   617     #####:  415:            u8 c = NET_SERIAL_TYPES[(u8)e->data->type];
   618         -:  416:            // set bit 4 when true
   619     #####:  417:            if (((sBoolt *)(e->data))->value)
   620 branch  0 never executed
   621 branch  1 never executed
   622     #####:  418:              c |= (1<<4);
   623     #####:  419:            sBytesPush(r, c);
   624 call    0 never executed
   625         -:  420:           }
   626     #####:  421:          break;
   627         -:  422:        case CONTAINER:
   628         -:  423:          // undefined
   629     #####:  424:          sBytesPush(r, NET_SERIAL_TYPES[(u8)e->data->type]);
   630 call    0 never executed
   631     #####:  425:          break;
   632         -:  426:        case DICT:
   633     #####:  427:          dictNetSerialLevel0(r, (sDictt *)(e->data));
   634 call    0 never executed
   635     #####:  428:          break;
   636         -:  429:        case DOUBLE:
   637     #####:  430:          sBytesPush(r, NET_SERIAL_TYPES[(u8)e->data->type]);
   638 call    0 never executed
   639     #####:  431:          sBytesPushBuffer(r, &((sDoublet *)(e->data))->value, sizeof(double));
   640 call    0 never executed
   641     #####:  432:          break;
   642         -:  433:        case INT: {
   643         -:  434:            // encode int to varint
   644         -:  435:            // v is int64_t to convert to varint
   645     #####:  436:            i64 v = ((sIntt *)(e->data))->value;
   646         -:  437:            // encode v with arithmetic shifts
   647     #####:  438:            uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->data->type], (v << 1) ^ (v >> 63));
   648 call    0 never executed
   649         -:  439:           }
   650     #####:  440:          break;
   651         -:  441:        case STRING:
   652     #####:  442:          sBytesPush(r, NET_SERIAL_TYPES[(u8)e->data->type]);
   653 call    0 never executed
   654     #####:  443:          sBytesPushBuffer(r, &((sStringt *)(e->data))->data, sizeof(sStringt) + strlen(&(((sStringt *)(e->data))->data)) -1);
   655 call    0 never executed
   656     #####:  444:          break;
   657         -:  445:        case ARRAY:
   658     #####:  446:          arrayNetSerialLevel0(r, (sArrayt *)(e->data));
   659 call    0 never executed
   660     #####:  447:          break;
   661         -:  448:        case BYTES:
   662     #####:  449:          B = (sBytest *)(e->data);
   663     #####:  450:          uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->data->type], B->count);
   664 call    0 never executed
   665     #####:  451:          sBytesPushBuffer(r, &(B->data), B->count);
   666 call    0 never executed
   667     #####:  452:          break;
   668         -:  453:       }
   669         -:  454:     }
   670         -:  455:  }
   671     #####:  456:  ret;
   672         -:  457:}
   673         -:  458:
   674         -:  459:/**
   675         -:  460: * serialize array
   676         -:  461: *
   677         -:  462: * the serialized array is pushed to r.
   678         -:  463: * All elements are serialized recursively
   679         -:  464: *
   680         -:  465: * the data in containers is not serialized
   681         -:  466: *
   682         -:  467: * \param
   683         -:  468: *   r small bytes object
   684         -:  469: *   array to serialize
   685         -:  470: */
   686 function arrayNetSerialLevel0 called 0 returned 0% blocks executed 0%
   687     #####:  471:internal void arrayNetSerialLevel0(sBytest **r, sArrayt *array) {
   688     #####:  472:  sBytest *B = NULL;
   689         -:  473:
   690     #####:  474:  uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)array->type], array->count);
   691 call    0 never executed
   692         -:  475:
   693     #####:  476:  forEachSArray(array, e) {
   694 branch  0 never executed
   695 branch  1 never executed
   696     #####:  477:    if (!e) {
   697 branch  0 never executed
   698 branch  1 never executed
   699         -:  478:      // empty slots are represented as undefined elements
   700     #####:  479:      sBytesPush(r, NET_SERIAL_TYPES[UNDEFINED]);
   701 call    0 never executed
   702         -:  480:    }
   703         -:  481:    else {
   704     #####:  482:      switch(e->type) {
   705 branch  0 never executed
   706 branch  1 never executed
   707 branch  2 never executed
   708 branch  3 never executed
   709 branch  4 never executed
   710 branch  5 never executed
   711 branch  6 never executed
   712 branch  7 never executed
   713 branch  8 never executed
   714 branch  9 never executed
   715         -:  483:        case UNDEFINED:
   716     #####:  484:          sBytesPush(r, NET_SERIAL_TYPES[(u8)e->type]);
   717 call    0 never executed
   718     #####:  485:          break;
   719         -:  486:        case BOOL: {
   720     #####:  487:            u8 c = NET_SERIAL_TYPES[(u8)e->type];
   721         -:  488:            // set bit 4 when true
   722     #####:  489:            if (((sBoolt *)&(e->type))->value)
   723 branch  0 never executed
   724 branch  1 never executed
   725     #####:  490:              c |= (1<<4);
   726     #####:  491:            sBytesPush(r, c);
   727 call    0 never executed
   728         -:  492:          }
   729     #####:  493:          break;
   730         -:  494:        case CONTAINER:
   731         -:  495:          // undefined
   732     #####:  496:          sBytesPush(r, NET_SERIAL_TYPES[(u8)e->type]);
   733 call    0 never executed
   734     #####:  497:          break;
   735         -:  498:        case DICT:
   736     #####:  499:          dictNetSerialLevel0(r, (sDictt *)e);
   737 call    0 never executed
   738     #####:  500:          break;
   739         -:  501:        case DOUBLE:
   740     #####:  502:          sBytesPush(r, NET_SERIAL_TYPES[(u8)e->type]);
   741 call    0 never executed
   742     #####:  503:          sBytesPushBuffer(r, &((sDoublet *)e)->value, sizeof(double));
   743 call    0 never executed
   744     #####:  504:          break;
   745         -:  505:        case INT: {
   746         -:  506:            // encode int to varint
   747         -:  507:            // v is int64_t to convert to varint
   748     #####:  508:            i64 v = ((sIntt *)&(e->type))->value;
   749         -:  509:            // encode v with arithmetic shifts
   750     #####:  510:            uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->type], (v << 1) ^ (v >> 63));
   751 call    0 never executed
   752         -:  511:          }
   753     #####:  512:          break;
   754         -:  513:        case STRING:
   755     #####:  514:          sBytesPush(r, NET_SERIAL_TYPES[(u8)e->type]);
   756 call    0 never executed
   757     #####:  515:          sBytesPushBuffer(r, &((sStringt *)e)->data, sizeof(sStringt) + strlen(&(((sStringt *)e)->data)) -1);
   758 call    0 never executed
   759     #####:  516:          break;
   760         -:  517:        case ARRAY:
   761     #####:  518:          arrayNetSerialLevel0(r, (sArrayt *)e);
   762 call    0 never executed
   763     #####:  519:          break;
   764         -:  520:        case BYTES:
   765     #####:  521:          B = (sBytest *)e;
   766     #####:  522:          uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->type], B->count);
   767 call    0 never executed
   768     #####:  523:          sBytesPushBuffer(r, &(B->data), B->count);
   769 call    0 never executed
   770     #####:  524:          break;
   771         -:  525:      }
   772         -:  526:    }
   773         -:  527:  }
   774     #####:  528:  ret;
   775         -:  529:}
   776         -:  530:
   777 function serialNetSerialLevel0 called 0 returned 0% blocks executed 0%
   778     #####:  531:internal smallBytest* serialNetSerialLevel0(smallJsont *self) {
   779         -:  532:
   780     #####:  533:  smallt *o = getsoG(self);
   781 call    0 never executed
   782         -:  534:
   783     #####:  535:  if (o == NULL)
   784 branch  0 never executed
   785 branch  1 never executed
   786     #####:  536:    ret NULL;
   787         -:  537:
   788     #####:  538:  sBytest *B = netSerialLevel0(o);
   789 call    0 never executed
   790         -:  539:
   791     #####:  540:  if (!B) {
   792 branch  0 never executed
   793 branch  1 never executed
   794     #####:  541:    ret NULL;
   795         -:  542:  }
   796         -:  543:
   797     #####:  544:  createAllocateSmallBytes(r);
   798 call    0 never executed
   799     #####:  545:  r->B = B;
   800     #####:  546:  ret r;
   801         -:  547:}
   802         -:  548:
   803         -:  549:// level 1
   804         -:  550:// like level 0 with type encoded in nibbles and bools are packed
   805         -:  551:
   806         -:  552:/**
   807         -:  553: * serializer top function
   808         -:  554: */
   809 function netSerialLevel1 called 0 returned 0% blocks executed 0%
   810     #####:  555:internal sBytest* netSerialLevel1(smallt *o) {
   811     #####:  556:  sBytest *r = NULL;
   812     #####:  557:  sBytest *B = NULL;
   813     #####:  558:  contextt ctx = {.nibble=lowNbl, .nblOffset=0, .boolShift = 0, .boolOffset=0};
   814         -:  559:
   815     #####:  560:  switch(o->type) {
   816 branch  0 never executed
   817 branch  1 never executed
   818 branch  2 never executed
   819 branch  3 never executed
   820 branch  4 never executed
   821 branch  5 never executed
   822 branch  6 never executed
   823 branch  7 never executed
   824 branch  8 never executed
   825         -:  561:    case UNDEFINED:
   826         -:  562:    case CONTAINER:
   827     #####:  563:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
   828 call    0 never executed
   829     #####:  564:      break;
   830         -:  565:    case BOOL: {
   831     #####:  566:      u8 c = NET_SERIAL_TYPES[(u8)o->type];
   832         -:  567:      // set bit 4 when true
   833     #####:  568:      if (((sBoolt *)&(o->type))->value)
   834 branch  0 never executed
   835 branch  1 never executed
   836     #####:  569:        c |= (1<<4);
   837     #####:  570:      sBytesPush(&r, c);
   838 call    0 never executed
   839         -:  571:      }
   840     #####:  572:      break;
   841         -:  573:    case DICT:
   842     #####:  574:      dictNetSerialLevel1(&r, (sDictt *)&(o->type), &ctx);
   843 call    0 never executed
   844     #####:  575:      break;
   845         -:  576:    case DOUBLE:
   846     #####:  577:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
   847 call    0 never executed
   848     #####:  578:      sBytesPushBuffer(&r, &((sDoublet *)&(o->type))->value, sizeof(double));
   849 call    0 never executed
   850     #####:  579:      break;
   851         -:  580:    case INT: {
   852         -:  581:      // encode int to varint
   853         -:  582:      // v is int64_t to convert to varint
   854     #####:  583:      i64 v = ((sIntt *)&(o->type))->value;
   855         -:  584:      // encode v with arithmetic shifts
   856     #####:  585:      uintToNetTypeVarint(&r, NET_SERIAL_TYPES[(u8)o->type], (v << 1) ^ (v >> 63));
   857 call    0 never executed
   858         -:  586:      }
   859     #####:  587:      break;
   860         -:  588:    case STRING:
   861     #####:  589:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
   862 call    0 never executed
   863     #####:  590:      sBytesPushBuffer(&r, &((sStringt *)&(o->type))->data, sizeof(sStringt) + strlen(&(((sStringt *)&(o->type))->data)) -1);
   864 call    0 never executed
   865     #####:  591:      break;
   866         -:  592:    case ARRAY:
   867     #####:  593:      arrayNetSerialLevel1(&r, (sArrayt *)&(o->type), &ctx);
   868 call    0 never executed
   869     #####:  594:      break;
   870         -:  595:    case BYTES:
   871     #####:  596:      B = (sBytest *)&(o->type);
   872     #####:  597:      uintToNetTypeVarint(&r, NET_SERIAL_TYPES[(u8)o->type], B->count);
   873 call    0 never executed
   874     #####:  598:      sBytesPushBuffer(&r, &(B->data), B->count);
   875 call    0 never executed
   876     #####:  599:      break;
   877         -:  600:  }
   878     #####:  601:  ret r;
   879         -:  602:}
   880         -:  603:
   881         -:  604:/**
   882         -:  605: * serialize dictionary
   883         -:  606: *
   884         -:  607: * the serialized dict is pushed to r.
   885         -:  608: * All elements are serialized recursively
   886         -:  609: *
   887         -:  610: * the data in containers is not serialized
   888         -:  611: *
   889         -:  612: * \param
   890         -:  613: *   r small bytes object
   891         -:  614: *   dict dictionary to serialize
   892         -:  615: */
   893 function dictNetSerialLevel1 called 0 returned 0% blocks executed 0%
   894     #####:  616:internal void dictNetSerialLevel1(sBytest **r, sDictt *dict, contextt *ctx) {
   895     #####:  617:  sBytest *B     = NULL;
   896     #####:  618:  char    *data  = NULL;
   897         -:  619:
   898     #####:  620:  if (ctx->nibble == lowNbl) {
   899 branch  0 never executed
   900 branch  1 never executed
   901     #####:  621:    uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)dict->type], dict->count);
   902 call    0 never executed
   903         -:  622:  }
   904         -:  623:  else {
   905         -:  624:    // high nibble
   906         -:  625:    #define storeTypeInHighNbl(o)\
   907         -:  626:    ctx->nibble  = lowNbl;\
   908         -:  627:    data         = (char *)&((*r)->data) + ctx->nblOffset;\
   909         -:  628:    *data       |= NET_SERIAL_TYPES[(u8)o->type] << 4
   910     #####:  629:    storeTypeInHighNbl(dict);
   911     #####:  630:    uintToVarint(r, dict->count);
   912 call    0 never executed
   913         -:  631:  }
   914         -:  632:
   915     #####:  633:  forEachSDict(dict, e) {
   916 branch  0 never executed
   917 branch  1 never executed
   918     #####:  634:    if (e->key) {
   919 branch  0 never executed
   920 branch  1 never executed
   921     #####:  635:      sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
   922 call    0 never executed
   923         -:  636:
   924     #####:  637:      switch(e->data->type) {
   925 branch  0 never executed
   926 branch  1 never executed
   927 branch  2 never executed
   928 branch  3 never executed
   929 branch  4 never executed
   930 branch  5 never executed
   931 branch  6 never executed
   932 branch  7 never executed
   933 branch  8 never executed
   934         -:  638:        case UNDEFINED:
   935         -:  639:        case CONTAINER:
   936     #####:  640:          if (ctx->nibble == lowNbl) {
   937 branch  0 never executed
   938 branch  1 never executed
   939         -:  641:            #define storeTypeOnly(o)\
   940         -:  642:            sBytesPush(r, NET_SERIAL_TYPES[(u8)o->type]);\
   941         -:  643:            ctx->nibble    = highNbl;\
   942         -:  644:            ctx->nblOffset = (*r)->count -1
   943     #####:  645:            storeTypeOnly(e->data);
   944 call    0 never executed
   945         -:  646:          }
   946         -:  647:          else {
   947     #####:  648:            storeTypeInHighNbl(e->data);
   948         -:  649:          }
   949     #####:  650:          break;
   950         -:  651:        case BOOL:
   951     #####:  652:          if (!ctx->boolOffset) {
   952 branch  0 never executed
   953 branch  1 never executed
   954         -:  653:            // new packed bools
   955     #####:  654:            if (ctx->nibble == lowNbl) {
   956 branch  0 never executed
   957 branch  1 never executed
   958         -:  655:              #define storeNew4bPackedBool(o)\
   959         -:  656:              u8 c = NET_SERIAL_TYPES[(u8)o->type];\
   960         -:  657:              /* set bit 4 when true */\
   961         -:  658:              if (((sBoolt *)(o))->value)\
   962         -:  659:                c |= (1<<4);\
   963         -:  660:              sBytesPush(r, c);\
   964         -:  661:              ctx->boolShift  = 5;\
   965         -:  662:              ctx->boolOffset = (*r)->count -1
   966     #####:  663:              storeNew4bPackedBool(e->data);
   967 branch  0 never executed
   968 branch  1 never executed
   969 call    2 never executed
   970         -:  664:            }
   971         -:  665:            else {
   972         -:  666:              // high nibble, next byte is packed bools
   973     #####:  667:              storeTypeInHighNbl(e->data);
   974         -:  668:              #define storeNew8bPackedBool(o)\
   975         -:  669:              u8 c         = 0;\
   976         -:  670:              if (((sBoolt *)(o))->value)\
   977         -:  671:                c = 1;\
   978         -:  672:              sBytesPush(r, c);\
   979         -:  673:              ctx->boolShift  = 1;\
   980         -:  674:              ctx->boolOffset = (*r)->count -1
   981     #####:  675:              storeNew8bPackedBool(e->data);
   982 branch  0 never executed
   983 branch  1 never executed
   984 call    2 never executed
   985         -:  676:            }
   986         -:  677:          }
   987         -:  678:          else {
   988         -:  679:            // there was a bool before this one, fill bits in nibbles
   989     #####:  680:            if (ctx->nibble == lowNbl) {
   990 branch  0 never executed
   991 branch  1 never executed
   992     #####:  681:              if (ctx->boolShift == 8) {
   993 branch  0 never executed
   994 branch  1 never executed
   995         -:  682:                // previous packed bool is full
   996         -:  683:                // this byte is the new packed bools
   997     #####:  684:                storeNew4bPackedBool(e->data);
   998 branch  0 never executed
   999 branch  1 never executed
  1000 call    2 never executed
  1001         -:  685:              }
  1002         -:  686:              else {
  1003     #####:  687:                storeTypeOnly(e->data);
  1004 call    0 never executed
  1005         -:  688:                #define storeBool(o)\
  1006         -:  689:                data           = (char *)&((*r)->data) + ctx->boolOffset;\
  1007         -:  690:                if (((sBoolt *)(o))->value)\
  1008         -:  691:                  *data |= 1 << ctx->boolShift;\
  1009         -:  692:                ctx->boolShift++
  1010     #####:  693:                storeBool(e->data);
  1011 branch  0 never executed
  1012 branch  1 never executed
  1013         -:  694:              }
  1014         -:  695:            }
  1015         -:  696:            else {
  1016         -:  697:              // high nibble
  1017     #####:  698:              storeTypeInHighNbl(e->data);
  1018     #####:  699:              if (ctx->boolShift == 8) {
  1019 branch  0 never executed
  1020 branch  1 never executed
  1021         -:  700:                // previous packed bool is full
  1022         -:  701:                // next byte is the new packed bools
  1023     #####:  702:                storeNew8bPackedBool(e->data);
  1024 branch  0 never executed
  1025 branch  1 never executed
  1026 call    2 never executed
  1027         -:  703:              }
  1028         -:  704:              else {
  1029     #####:  705:                storeBool(e->data);
  1030 branch  0 never executed
  1031 branch  1 never executed
  1032         -:  706:              }
  1033         -:  707:            }
  1034         -:  708:          }
  1035     #####:  709:          break;
  1036         -:  710:        case DICT:
  1037     #####:  711:          dictNetSerialLevel1(r, (sDictt *)(e->data), ctx);
  1038 call    0 never executed
  1039     #####:  712:          break;
  1040         -:  713:        case DOUBLE:
  1041     #####:  714:          if (ctx->nibble == lowNbl) {
  1042 branch  0 never executed
  1043 branch  1 never executed
  1044     #####:  715:            storeTypeOnly(e->data);
  1045 call    0 never executed
  1046         -:  716:          }
  1047         -:  717:          else {
  1048         -:  718:            // high nibble
  1049     #####:  719:            storeTypeInHighNbl(e->data);
  1050         -:  720:          }
  1051     #####:  721:          sBytesPushBuffer(r, &((sDoublet *)(e->data))->value, sizeof(double));
  1052 call    0 never executed
  1053     #####:  722:          break;
  1054         -:  723:        case INT: {
  1055         -:  724:            // encode int to varint
  1056         -:  725:            // v is int64_t to convert to varint
  1057     #####:  726:            i64 v = ((sIntt *)(e->data))->value;
  1058     #####:  727:            if (ctx->nibble == lowNbl) {
  1059 branch  0 never executed
  1060 branch  1 never executed
  1061         -:  728:              // encode v with arithmetic shifts
  1062     #####:  729:              uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->data->type], (v << 1) ^ (v >> 63));
  1063 call    0 never executed
  1064         -:  730:            }
  1065         -:  731:            else {
  1066         -:  732:              // high nibble
  1067     #####:  733:              storeTypeInHighNbl(e->data);
  1068     #####:  734:              uintToVarint(r, (v << 1) ^ (v >> 63));
  1069 call    0 never executed
  1070         -:  735:            }
  1071         -:  736:          }
  1072     #####:  737:          break;
  1073         -:  738:        case STRING:
  1074     #####:  739:          if (ctx->nibble == lowNbl) {
  1075 branch  0 never executed
  1076 branch  1 never executed
  1077     #####:  740:            storeTypeOnly(e->data);
  1078 call    0 never executed
  1079         -:  741:          }
  1080         -:  742:          else {
  1081         -:  743:            // high nibble
  1082     #####:  744:            storeTypeInHighNbl(e->data);
  1083         -:  745:          }
  1084     #####:  746:          sBytesPushBuffer(r, &((sStringt *)(e->data))->data, sizeof(sStringt) + strlen(&(((sStringt *)(e->data))->data)) -1);
  1085 call    0 never executed
  1086     #####:  747:          break;
  1087         -:  748:        case ARRAY:
  1088     #####:  749:          arrayNetSerialLevel1(r, (sArrayt *)(e->data), ctx);
  1089 call    0 never executed
  1090     #####:  750:          break;
  1091         -:  751:        case BYTES:
  1092     #####:  752:          B = (sBytest *)(e->data);
  1093     #####:  753:          if (ctx->nibble == lowNbl) {
  1094 branch  0 never executed
  1095 branch  1 never executed
  1096     #####:  754:            uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->data->type], B->count);
  1097 call    0 never executed
  1098         -:  755:          }
  1099         -:  756:          else {
  1100         -:  757:            // high nibble
  1101     #####:  758:            storeTypeInHighNbl(e->data);
  1102     #####:  759:            uintToVarint(r, B->count);
  1103 call    0 never executed
  1104         -:  760:          }
  1105     #####:  761:          sBytesPushBuffer(r, &(B->data), B->count);
  1106 call    0 never executed
  1107     #####:  762:          break;
  1108         -:  763:      }
  1109         -:  764:    }
  1110         -:  765:  }
  1111     #####:  766:  ret;
  1112         -:  767:}
  1113         -:  768:
  1114         -:  769:/**
  1115         -:  770: * serialize array
  1116         -:  771: *
  1117         -:  772: * the serialized array is pushed to r.
  1118         -:  773: * All elements are serialized recursively
  1119         -:  774: *
  1120         -:  775: * the data in containers is not serialized
  1121         -:  776: *
  1122         -:  777: * \param
  1123         -:  778: *   r small bytes object
  1124         -:  779: *   array to serialize
  1125         -:  780: */
  1126 function arrayNetSerialLevel1 called 0 returned 0% blocks executed 0%
  1127     #####:  781:internal void arrayNetSerialLevel1(sBytest **r, sArrayt *array, contextt *ctx) {
  1128     #####:  782:  sBytest *B     = NULL;
  1129     #####:  783:  char    *data  = NULL;
  1130         -:  784:
  1131     #####:  785:  if (ctx->nibble == lowNbl) {
  1132 branch  0 never executed
  1133 branch  1 never executed
  1134     #####:  786:    uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)array->type], array->count);
  1135 call    0 never executed
  1136         -:  787:  }
  1137         -:  788:  else {
  1138         -:  789:    // high nibble
  1139     #####:  790:    storeTypeInHighNbl(array);
  1140     #####:  791:    uintToVarint(r, array->count);
  1141 call    0 never executed
  1142         -:  792:  }
  1143         -:  793:
  1144     #####:  794:  forEachSArray(array, e) {
  1145 branch  0 never executed
  1146 branch  1 never executed
  1147     #####:  795:    if (!e) {
  1148 branch  0 never executed
  1149 branch  1 never executed
  1150         -:  796:      // empty slots are represented as undefined elements
  1151     #####:  797:      if (ctx->nibble == lowNbl) {
  1152 branch  0 never executed
  1153 branch  1 never executed
  1154     #####:  798:        sBytesPush(r, NET_SERIAL_TYPES[UNDEFINED]);
  1155 call    0 never executed
  1156     #####:  799:        ctx->nibble    = highNbl;
  1157     #####:  800:        ctx->nblOffset = (*r)->count -1;
  1158         -:  801:      }
  1159         -:  802:      else {
  1160         -:  803:        // high nibble
  1161     #####:  804:        ctx->nibble  = lowNbl;
  1162     #####:  805:        data         = (char *)&((*r)->data) + ctx->nblOffset;
  1163     #####:  806:        *data       |= NET_SERIAL_TYPES[UNDEFINED] << 4;
  1164         -:  807:      }
  1165         -:  808:    }
  1166         -:  809:    else {
  1167     #####:  810:      switch(e->type) {
  1168 branch  0 never executed
  1169 branch  1 never executed
  1170 branch  2 never executed
  1171 branch  3 never executed
  1172 branch  4 never executed
  1173 branch  5 never executed
  1174 branch  6 never executed
  1175 branch  7 never executed
  1176 branch  8 never executed
  1177         -:  811:        case UNDEFINED:
  1178         -:  812:        case CONTAINER:
  1179     #####:  813:          if (ctx->nibble == lowNbl) {
  1180 branch  0 never executed
  1181 branch  1 never executed
  1182     #####:  814:            storeTypeOnly(e);
  1183 call    0 never executed
  1184         -:  815:          }
  1185         -:  816:          else {
  1186         -:  817:            // high nibble
  1187     #####:  818:            storeTypeInHighNbl(e);
  1188         -:  819:          }
  1189     #####:  820:          break;
  1190         -:  821:        case BOOL:
  1191     #####:  822:          if (!ctx->boolOffset) {
  1192 branch  0 never executed
  1193 branch  1 never executed
  1194         -:  823:            // new packed bools
  1195     #####:  824:            if (ctx->nibble == lowNbl) {
  1196 branch  0 never executed
  1197 branch  1 never executed
  1198     #####:  825:              storeNew4bPackedBool(e);
  1199 branch  0 never executed
  1200 branch  1 never executed
  1201 call    2 never executed
  1202         -:  826:            }
  1203         -:  827:            else {
  1204         -:  828:              // high nibble, next byte is packed bools
  1205     #####:  829:              storeTypeInHighNbl(e);
  1206     #####:  830:              storeNew8bPackedBool(e);
  1207 branch  0 never executed
  1208 branch  1 never executed
  1209 call    2 never executed
  1210         -:  831:            }
  1211         -:  832:          }
  1212         -:  833:          else {
  1213         -:  834:            // there was a bool before this one, fill bits in nibbles
  1214     #####:  835:            if (ctx->nibble == lowNbl) {
  1215 branch  0 never executed
  1216 branch  1 never executed
  1217     #####:  836:              if (ctx->boolShift == 8) {
  1218 branch  0 never executed
  1219 branch  1 never executed
  1220         -:  837:                // previous packed bool is full
  1221         -:  838:                // this byte is the new packed bools
  1222     #####:  839:                storeNew4bPackedBool(e);
  1223 branch  0 never executed
  1224 branch  1 never executed
  1225 call    2 never executed
  1226         -:  840:              }
  1227         -:  841:              else {
  1228     #####:  842:                storeTypeOnly(e);
  1229 call    0 never executed
  1230     #####:  843:                storeBool(e);
  1231 branch  0 never executed
  1232 branch  1 never executed
  1233         -:  844:              }
  1234         -:  845:            }
  1235         -:  846:            else {
  1236         -:  847:              // high nibble
  1237     #####:  848:              storeTypeInHighNbl(e);
  1238     #####:  849:              if (ctx->boolShift == 8) {
  1239 branch  0 never executed
  1240 branch  1 never executed
  1241         -:  850:                // previous packed bool is full
  1242         -:  851:                // next byte is the new packed bools
  1243     #####:  852:                storeNew8bPackedBool(e);
  1244 branch  0 never executed
  1245 branch  1 never executed
  1246 call    2 never executed
  1247         -:  853:              }
  1248         -:  854:              else {
  1249     #####:  855:                storeBool(e);
  1250 branch  0 never executed
  1251 branch  1 never executed
  1252         -:  856:              }
  1253         -:  857:            }
  1254         -:  858:          }
  1255     #####:  859:          break;
  1256         -:  860:        case DICT:
  1257     #####:  861:          dictNetSerialLevel1(r, (sDictt *)e, ctx);
  1258 call    0 never executed
  1259     #####:  862:          break;
  1260         -:  863:        case DOUBLE:
  1261     #####:  864:          if (ctx->nibble == lowNbl) {
  1262 branch  0 never executed
  1263 branch  1 never executed
  1264     #####:  865:            storeTypeOnly(e);
  1265 call    0 never executed
  1266         -:  866:          }
  1267         -:  867:          else {
  1268         -:  868:            // high nibble
  1269     #####:  869:            storeTypeInHighNbl(e);
  1270         -:  870:          }
  1271     #####:  871:          sBytesPushBuffer(r, &((sDoublet *)e)->value, sizeof(double));
  1272 call    0 never executed
  1273     #####:  872:          break;
  1274         -:  873:        case INT: {
  1275         -:  874:            // encode int to varint
  1276         -:  875:            // v is int64_t to convert to varint
  1277     #####:  876:            i64 v = ((sIntt *)&(e->type))->value;
  1278     #####:  877:            if (ctx->nibble == lowNbl) {
  1279 branch  0 never executed
  1280 branch  1 never executed
  1281         -:  878:              // encode v with arithmetic shifts
  1282     #####:  879:              uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->type], (v << 1) ^ (v >> 63));
  1283 call    0 never executed
  1284         -:  880:            }
  1285         -:  881:            else {
  1286         -:  882:              // high nibble
  1287     #####:  883:              storeTypeInHighNbl(e);
  1288     #####:  884:              uintToVarint(r, (v << 1) ^ (v >> 63));
  1289 call    0 never executed
  1290         -:  885:            }
  1291         -:  886:          }
  1292     #####:  887:          break;
  1293         -:  888:        case STRING:
  1294     #####:  889:          if (ctx->nibble == lowNbl) {
  1295 branch  0 never executed
  1296 branch  1 never executed
  1297     #####:  890:            storeTypeOnly(e);
  1298 call    0 never executed
  1299         -:  891:          }
  1300         -:  892:          else {
  1301         -:  893:            // high nibble
  1302     #####:  894:            storeTypeInHighNbl(e);
  1303         -:  895:          }
  1304     #####:  896:          sBytesPushBuffer(r, &((sStringt *)e)->data, sizeof(sStringt) + strlen(&(((sStringt *)e)->data)) -1);
  1305 call    0 never executed
  1306     #####:  897:          break;
  1307         -:  898:        case ARRAY:
  1308     #####:  899:          arrayNetSerialLevel1(r, (sArrayt *)e, ctx);
  1309 call    0 never executed
  1310     #####:  900:          break;
  1311         -:  901:        case BYTES:
  1312     #####:  902:          B = (sBytest *)e;
  1313     #####:  903:          if (ctx->nibble == lowNbl) {
  1314 branch  0 never executed
  1315 branch  1 never executed
  1316     #####:  904:            uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->type], B->count);
  1317 call    0 never executed
  1318         -:  905:          }
  1319         -:  906:          else {
  1320         -:  907:            // high nibble
  1321     #####:  908:            storeTypeInHighNbl(e);
  1322     #####:  909:            uintToVarint(r, B->count);
  1323 call    0 never executed
  1324         -:  910:          }
  1325     #####:  911:          sBytesPushBuffer(r, &(B->data), B->count);
  1326 call    0 never executed
  1327     #####:  912:          break;
  1328         -:  913:      }
  1329         -:  914:    }
  1330         -:  915:  }
  1331     #####:  916:  ret;
  1332         -:  917:}
  1333         -:  918:
  1334 function serialNetSerialLevel1 called 0 returned 0% blocks executed 0%
  1335     #####:  919:internal smallBytest* serialNetSerialLevel1(smallJsont *self) {
  1336         -:  920:
  1337     #####:  921:  smallt *o = getsoG(self);
  1338 call    0 never executed
  1339         -:  922:
  1340     #####:  923:  if (o == NULL)
  1341 branch  0 never executed
  1342 branch  1 never executed
  1343     #####:  924:    ret NULL;
  1344         -:  925:
  1345     #####:  926:  sBytest *B = netSerialLevel1(o);
  1346 call    0 never executed
  1347         -:  927:
  1348     #####:  928:  if (!B) {
  1349 branch  0 never executed
  1350 branch  1 never executed
  1351     #####:  929:    ret NULL;
  1352         -:  930:  }
  1353         -:  931:
  1354     #####:  932:  createAllocateSmallBytes(r);
  1355 call    0 never executed
  1356     #####:  933:  r->B = B;
  1357     #####:  934:  ret r;
  1358         -:  935:}
  1359         -:  936:
  1360         -:  937:// level 2
  1361         -:  938:// like level 1, arrays are set to uniform when all elements are same type
  1362         -:  939:
  1363         -:  940:/**
  1364         -:  941: * serializer top function
  1365         -:  942: */
  1366 function netSerialLevel2 called 0 returned 0% blocks executed 0%
  1367     #####:  943:internal sBytest* netSerialLevel2(smallt *o) {
  1368     #####:  944:  sBytest *r = NULL;
  1369     #####:  945:  sBytest *B = NULL;
  1370     #####:  946:  contextt ctx = {.nibble=lowNbl, .nblOffset=0, .boolShift = 0, .boolOffset=0};
  1371         -:  947:
  1372     #####:  948:  switch(o->type) {
  1373 branch  0 never executed
  1374 branch  1 never executed
  1375 branch  2 never executed
  1376 branch  3 never executed
  1377 branch  4 never executed
  1378 branch  5 never executed
  1379 branch  6 never executed
  1380 branch  7 never executed
  1381 branch  8 never executed
  1382         -:  949:    case UNDEFINED:
  1383         -:  950:    case CONTAINER:
  1384     #####:  951:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
  1385 call    0 never executed
  1386     #####:  952:      break;
  1387         -:  953:    case BOOL: {
  1388     #####:  954:      u8 c = NET_SERIAL_TYPES[(u8)o->type];
  1389         -:  955:      // set bit 4 when true
  1390     #####:  956:      if (((sBoolt *)&(o->type))->value)
  1391 branch  0 never executed
  1392 branch  1 never executed
  1393     #####:  957:        c |= (1<<4);
  1394     #####:  958:      sBytesPush(&r, c);
  1395 call    0 never executed
  1396         -:  959:      }
  1397     #####:  960:      break;
  1398         -:  961:    case DICT:
  1399     #####:  962:      dictNetSerialLevel2(&r, (sDictt *)&(o->type), &ctx, /*packed=*/false);
  1400 call    0 never executed
  1401     #####:  963:      break;
  1402         -:  964:    case DOUBLE:
  1403     #####:  965:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
  1404 call    0 never executed
  1405     #####:  966:      sBytesPushBuffer(&r, &((sDoublet *)&(o->type))->value, sizeof(double));
  1406 call    0 never executed
  1407     #####:  967:      break;
  1408         -:  968:    case INT: {
  1409         -:  969:      // encode int to varint
  1410         -:  970:      // v is int64_t to convert to varint
  1411     #####:  971:      i64 v = ((sIntt *)&(o->type))->value;
  1412         -:  972:      // encode v with arithmetic shifts
  1413     #####:  973:      uintToNetTypeVarint(&r, NET_SERIAL_TYPES[(u8)o->type], (v << 1) ^ (v >> 63));
  1414 call    0 never executed
  1415         -:  974:      }
  1416     #####:  975:      break;
  1417         -:  976:    case STRING:
  1418     #####:  977:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
  1419 call    0 never executed
  1420     #####:  978:      sBytesPushBuffer(&r, &((sStringt *)&(o->type))->data, sizeof(sStringt) + strlen(&(((sStringt *)&(o->type))->data)) -1);
  1421 call    0 never executed
  1422     #####:  979:      break;
  1423         -:  980:    case ARRAY:
  1424     #####:  981:      arrayNetSerialLevel2(&r, (sArrayt *)&(o->type), &ctx, /*packed=*/false);
  1425 call    0 never executed
  1426     #####:  982:      break;
  1427         -:  983:    case BYTES:
  1428     #####:  984:      B = (sBytest *)&(o->type);
  1429     #####:  985:      uintToNetTypeVarint(&r, NET_SERIAL_TYPES[(u8)o->type], B->count);
  1430 call    0 never executed
  1431     #####:  986:      sBytesPushBuffer(&r, &(B->data), B->count);
  1432 call    0 never executed
  1433     #####:  987:      break;
  1434         -:  988:  }
  1435     #####:  989:  ret r;
  1436         -:  990:}
  1437         -:  991:
  1438 function isDictUniform called 33 returned 100% blocks executed 69%
  1439        33:  992:internal u8 isDictUniform(sDictt *dict) {
  1440        33:  993:  bool allElementsHaveSameType = true;
  1441        33:  994:  bool foundFirstType          = false;
  1442        33:  995:  u8 type                      = 0;
  1443        66:  996:  forEachSDict(dict, e) {
  1444 branch  0 taken 67%
  1445 branch  1 taken 33% (fallthrough)
  1446        44:  997:    if (e->key) {
  1447 branch  0 taken 100% (fallthrough)
  1448 branch  1 taken 0%
  1449        44:  998:      if (foundFirstType) {
  1450 branch  0 taken 39% (fallthrough)
  1451 branch  1 taken 61%
  1452         -:  999:        u8 nextType;
  1453        17: 1000:        switch(e->data->type) {
  1454 branch  0 taken 0%
  1455 branch  1 taken 0%
  1456 branch  2 taken 100%
  1457         -: 1001:          case DICT:
  1458     #####: 1002:            nextType = isDictUniform((sDictt*)e->data);
  1459 call    0 never executed
  1460     #####: 1003:            break;
  1461         -: 1004:          case ARRAY:
  1462     #####: 1005:            nextType = isArrayUniform((sArrayt*)e->data);
  1463 call    0 never executed
  1464     #####: 1006:            break;
  1465         -: 1007:          default:
  1466        17: 1008:            nextType = NET_SERIAL_TYPES[(u8)e->data->type];
  1467         -: 1009:        }
  1468        17: 1010:        if (nextType != type) {
  1469 branch  0 taken 65% (fallthrough)
  1470 branch  1 taken 35%
  1471        11: 1011:          allElementsHaveSameType = false;
  1472        11: 1012:          break;
  1473         -: 1013:        }
  1474         -: 1014:      }
  1475         -: 1015:      else {
  1476        27: 1016:        switch(e->data->type) {
  1477 branch  0 taken 0%
  1478 branch  1 taken 0%
  1479 branch  2 taken 100%
  1480         -: 1017:          case DICT:
  1481     #####: 1018:            type = isDictUniform((sDictt*)e->data);
  1482 call    0 never executed
  1483     #####: 1019:            break;
  1484         -: 1020:          case ARRAY:
  1485     #####: 1021:            type = isArrayUniform((sArrayt*)e->data);
  1486 call    0 never executed
  1487     #####: 1022:            break;
  1488         -: 1023:          default:
  1489        27: 1024:            type = NET_SERIAL_TYPES[(u8)e->data->type];
  1490         -: 1025:        }
  1491        27: 1026:        foundFirstType = true;
  1492         -: 1027:      }
  1493         -: 1028:    }
  1494         -: 1029:  }
  1495        33: 1030:  if (allElementsHaveSameType)
  1496 branch  0 taken 67% (fallthrough)
  1497 branch  1 taken 33%
  1498        22: 1031:    type = UNIFORM_DICT;
  1499         -: 1032:  else
  1500        11: 1033:    type = S_DICT;
  1501        33: 1034:  ret type;
  1502         -: 1035:}
  1503         -: 1036:
  1504 function isArrayUniform called 30 returned 100% blocks executed 65%
  1505        30: 1037:internal u8 isArrayUniform(sArrayt *array) {
  1506        30: 1038:  bool allElementsHaveSameType = true;
  1507        30: 1039:  bool foundFirstType          = false;
  1508        30: 1040:  char type                    = 0;
  1509        83: 1041:  forEachSArray(array, e) {
  1510 branch  0 taken 75%
  1511 branch  1 taken 25% (fallthrough)
  1512        62: 1042:    if (!e) {
  1513 branch  0 taken 0% (fallthrough)
  1514 branch  1 taken 100%
  1515     #####: 1043:      if (foundFirstType) {
  1516 branch  0 never executed
  1517 branch  1 never executed
  1518     #####: 1044:        if (type != S_UNDEFINED) {
  1519 branch  0 never executed
  1520 branch  1 never executed
  1521     #####: 1045:          allElementsHaveSameType = false;
  1522     #####: 1046:          break;
  1523         -: 1047:        }
  1524         -: 1048:      }
  1525         -: 1049:      else {
  1526     #####: 1050:        type = S_UNDEFINED;
  1527     #####: 1051:        foundFirstType = true;
  1528         -: 1052:      }
  1529         -: 1053:    }
  1530         -: 1054:    else {
  1531        62: 1055:      if (foundFirstType) {
  1532 branch  0 taken 56% (fallthrough)
  1533 branch  1 taken 44%
  1534         -: 1056:        u8 nextType;
  1535        35: 1057:        switch(e->type) {
  1536 branch  0 taken 0%
  1537 branch  1 taken 0%
  1538 branch  2 taken 100%
  1539         -: 1058:          case DICT:
  1540     #####: 1059:            nextType = isDictUniform((sDictt*)e);
  1541 call    0 never executed
  1542     #####: 1060:            break;
  1543         -: 1061:          case ARRAY:
  1544     #####: 1062:            nextType = isArrayUniform((sArrayt*)e);
  1545 call    0 never executed
  1546     #####: 1063:            break;
  1547         -: 1064:          default:
  1548        35: 1065:            nextType = NET_SERIAL_TYPES[(u8)e->type];
  1549         -: 1066:        }
  1550        35: 1067:        if (nextType != type) {
  1551 branch  0 taken 26% (fallthrough)
  1552 branch  1 taken 74%
  1553         9: 1068:          allElementsHaveSameType = false;
  1554         9: 1069:          break;
  1555         -: 1070:        }
  1556         -: 1071:      }
  1557         -: 1072:      else {
  1558        27: 1073:        switch(e->type) {
  1559 branch  0 taken 4%
  1560 branch  1 taken 0%
  1561 branch  2 taken 96%
  1562         -: 1074:          case DICT:
  1563         1: 1075:            type = isDictUniform((sDictt*)e);
  1564 call    0 returned 100%
  1565         1: 1076:            break;
  1566         -: 1077:          case ARRAY:
  1567     #####: 1078:            type = isArrayUniform((sArrayt*)e);
  1568 call    0 never executed
  1569     #####: 1079:            break;
  1570         -: 1080:          default:
  1571        26: 1081:            type = NET_SERIAL_TYPES[(u8)e->type];
  1572         -: 1082:        }
  1573        27: 1083:        foundFirstType = true;
  1574         -: 1084:      }
  1575         -: 1085:    }
  1576         -: 1086:  }
  1577        30: 1087:  if (allElementsHaveSameType)
  1578 branch  0 taken 70% (fallthrough)
  1579 branch  1 taken 30%
  1580        21: 1088:    type = UNIFORM_ARRAY;
  1581         -: 1089:  else
  1582         9: 1090:    type = S_ARRAY;
  1583        30: 1091:  ret type;
  1584         -: 1092:}
  1585         -: 1093:
  1586         -: 1094:/**
  1587         -: 1095: * serialize dictionary
  1588         -: 1096: *
  1589         -: 1097: * the serialized dict is pushed to r.
  1590         -: 1098: * All elements are serialized recursively
  1591         -: 1099: *
  1592         -: 1100: * the data in containers is not serialized
  1593         -: 1101: *
  1594         -: 1102: * \param
  1595         -: 1103: *   r small bytes object
  1596         -: 1104: *   dict dictionary to serialize
  1597         -: 1105: */
  1598 function dictNetSerialLevel2 called 0 returned 0% blocks executed 0%
  1599     #####: 1106:internal void dictNetSerialLevel2(sBytest **r, sDictt *dict, contextt *ctx, bool packed) {
  1600     #####: 1107:  sBytest *B     = NULL;
  1601     #####: 1108:  char    *data  = NULL;
  1602         -: 1109:
  1603         -: 1110:  // check if all elements have same type
  1604     #####: 1111:  bool allElementsHaveSameType = true;
  1605     #####: 1112:  bool foundFirstType          = false;
  1606     #####: 1113:  char type                    = 0;
  1607     #####: 1114:  {forEachSDict(dict, e) {
  1608 branch  0 never executed
  1609 branch  1 never executed
  1610     #####: 1115:    if (e->key) {
  1611 branch  0 never executed
  1612 branch  1 never executed
  1613     #####: 1116:      if (foundFirstType) {
  1614 branch  0 never executed
  1615 branch  1 never executed
  1616         -: 1117:        u8 nextType;
  1617     #####: 1118:        switch(e->data->type) {
  1618 branch  0 never executed
  1619 branch  1 never executed
  1620 branch  2 never executed
  1621         -: 1119:          case DICT:
  1622     #####: 1120:            nextType = isDictUniform((sDictt*)e->data);
  1623 call    0 never executed
  1624     #####: 1121:            break;
  1625         -: 1122:          case ARRAY:
  1626     #####: 1123:            nextType = isArrayUniform((sArrayt*)e->data);
  1627 call    0 never executed
  1628     #####: 1124:            break;
  1629         -: 1125:          default:
  1630     #####: 1126:            nextType = NET_SERIAL_TYPES[(u8)e->data->type];
  1631         -: 1127:        }
  1632     #####: 1128:        if (nextType != type) {
  1633 branch  0 never executed
  1634 branch  1 never executed
  1635     #####: 1129:          allElementsHaveSameType = false;
  1636     #####: 1130:          break;
  1637         -: 1131:        }
  1638         -: 1132:      }
  1639         -: 1133:      else {
  1640     #####: 1134:        switch(e->data->type) {
  1641 branch  0 never executed
  1642 branch  1 never executed
  1643 branch  2 never executed
  1644         -: 1135:          case DICT:
  1645     #####: 1136:            type = isDictUniform((sDictt*)e->data);
  1646 call    0 never executed
  1647     #####: 1137:            break;
  1648         -: 1138:          case ARRAY:
  1649     #####: 1139:            type = isArrayUniform((sArrayt*)e->data);
  1650 call    0 never executed
  1651     #####: 1140:            break;
  1652         -: 1141:          default:
  1653     #####: 1142:            type = NET_SERIAL_TYPES[(u8)e->data->type];
  1654         -: 1143:        }
  1655     #####: 1144:        foundFirstType = true;
  1656         -: 1145:      }
  1657         -: 1146:    }
  1658         -: 1147:  }}
  1659         -: 1148:
  1660     #####: 1149:  if (allElementsHaveSameType) {
  1661 branch  0 never executed
  1662 branch  1 never executed
  1663         -: 1150:    // pack dictionary
  1664     #####: 1151:    if (packed) {
  1665 branch  0 never executed
  1666 branch  1 never executed
  1667     #####: 1152:      uintToNetTypeVarint(r, type, dict->count);
  1668 call    0 never executed
  1669         -: 1153:    }
  1670         -: 1154:    else {
  1671     #####: 1155:      if (ctx->nibble == lowNbl) {
  1672 branch  0 never executed
  1673 branch  1 never executed
  1674     #####: 1156:        sBytesPush(r, (type << 4) + UNIFORM_DICT);
  1675 call    0 never executed
  1676     #####: 1157:        uintToVarint(r, dict->count);
  1677 call    0 never executed
  1678         -: 1158:      }
  1679         -: 1159:      else {
  1680         -: 1160:        // high nibble
  1681     #####: 1161:        ctx->nibble  = lowNbl;
  1682     #####: 1162:        data         = (char *)&((*r)->data) + ctx->nblOffset;
  1683     #####: 1163:        *data       |= UNIFORM_DICT << 4;
  1684     #####: 1164:        uintToNetTypeVarint(r, type, dict->count);
  1685 call    0 never executed
  1686         -: 1165:      }
  1687         -: 1166:    }
  1688         -: 1167:
  1689     #####: 1168:    switch(type) {
  1690 branch  0 never executed
  1691 branch  1 never executed
  1692 branch  2 never executed
  1693 branch  3 never executed
  1694 branch  4 never executed
  1695 branch  5 never executed
  1696 branch  6 never executed
  1697 branch  7 never executed
  1698 branch  8 never executed
  1699         -: 1169:      case S_UNDEFINED:
  1700     #####: 1170:        {forEachSDict(dict, e) {
  1701 branch  0 never executed
  1702 branch  1 never executed
  1703     #####: 1171:          if (e->key) {
  1704 branch  0 never executed
  1705 branch  1 never executed
  1706     #####: 1172:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  1707 call    0 never executed
  1708         -: 1173:          }
  1709         -: 1174:        }}
  1710         -: 1175:
  1711     #####: 1176:        break;
  1712         -: 1177:      case S_BOOL:
  1713     #####: 1178:        {forEachSDict(dict, e) {
  1714 branch  0 never executed
  1715 branch  1 never executed
  1716     #####: 1179:          if (e->key) {
  1717 branch  0 never executed
  1718 branch  1 never executed
  1719     #####: 1180:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  1720 call    0 never executed
  1721         -: 1181:
  1722     #####: 1182:            if (!ctx->boolOffset) {
  1723 branch  0 never executed
  1724 branch  1 never executed
  1725         -: 1183:              // new packed bools
  1726     #####: 1184:              storeNew8bPackedBool(e->data);
  1727 branch  0 never executed
  1728 branch  1 never executed
  1729 call    2 never executed
  1730         -: 1185:            }
  1731         -: 1186:            else {
  1732         -: 1187:              // there was a bool before this one, fill bits in nibbles
  1733     #####: 1188:              if (ctx->boolShift == 8) {
  1734 branch  0 never executed
  1735 branch  1 never executed
  1736         -: 1189:                // previous packed bool is full
  1737         -: 1190:                // next byte is the new packed bools
  1738     #####: 1191:                storeNew8bPackedBool(e->data);
  1739 branch  0 never executed
  1740 branch  1 never executed
  1741 call    2 never executed
  1742         -: 1192:              }
  1743         -: 1193:              else {
  1744     #####: 1194:                storeBool(e->data);
  1745 branch  0 never executed
  1746 branch  1 never executed
  1747         -: 1195:              }
  1748         -: 1196:            }
  1749         -: 1197:          }
  1750         -: 1198:        }}
  1751     #####: 1199:        break;
  1752         -: 1200:      case S_DICT:
  1753         -: 1201:      case UNIFORM_DICT:
  1754     #####: 1202:        {forEachSDict(dict, e) {
  1755 branch  0 never executed
  1756 branch  1 never executed
  1757     #####: 1203:          if (e->key) {
  1758 branch  0 never executed
  1759 branch  1 never executed
  1760     #####: 1204:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  1761 call    0 never executed
  1762     #####: 1205:            dictNetSerialLevel2(r, (sDictt *)(e->data), ctx, /*packed=*/true);
  1763 call    0 never executed
  1764         -: 1206:          }
  1765         -: 1207:        }}
  1766     #####: 1208:        break;
  1767         -: 1209:      case S_DOUBLE:
  1768     #####: 1210:        {forEachSDict(dict, e) {
  1769 branch  0 never executed
  1770 branch  1 never executed
  1771     #####: 1211:          if (e->key) {
  1772 branch  0 never executed
  1773 branch  1 never executed
  1774     #####: 1212:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  1775 call    0 never executed
  1776     #####: 1213:            sBytesPushBuffer(r, &((sDoublet *)(e->data))->value, sizeof(double));
  1777 call    0 never executed
  1778         -: 1214:          }
  1779         -: 1215:        }}
  1780     #####: 1216:        break;
  1781         -: 1217:      case S_INT:
  1782     #####: 1218:        {forEachSDict(dict, e) {
  1783 branch  0 never executed
  1784 branch  1 never executed
  1785     #####: 1219:          if (e->key) {
  1786 branch  0 never executed
  1787 branch  1 never executed
  1788     #####: 1220:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  1789 call    0 never executed
  1790     #####: 1221:            i64 v = ((sIntt *)(e->data))->value;
  1791     #####: 1222:            uintToVarint(r, (v << 1) ^ (v >> 63));
  1792 call    0 never executed
  1793         -: 1223:          }
  1794         -: 1224:        }}
  1795     #####: 1225:        break;
  1796         -: 1226:      case S_STRING:
  1797     #####: 1227:        {forEachSDict(dict, e) {
  1798 branch  0 never executed
  1799 branch  1 never executed
  1800     #####: 1228:          if (e->key) {
  1801 branch  0 never executed
  1802 branch  1 never executed
  1803     #####: 1229:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  1804 call    0 never executed
  1805     #####: 1230:            sBytesPushBuffer(r, &((sStringt *)(e->data))->data, sizeof(sStringt) + strlen(&(((sStringt *)(e->data))->data)) -1);
  1806 call    0 never executed
  1807         -: 1231:          }
  1808         -: 1232:        }}
  1809     #####: 1233:        break;
  1810         -: 1234:      case S_ARRAY:
  1811         -: 1235:      case UNIFORM_ARRAY:
  1812     #####: 1236:        {forEachSDict(dict, e) {
  1813 branch  0 never executed
  1814 branch  1 never executed
  1815     #####: 1237:          if (e->key) {
  1816 branch  0 never executed
  1817 branch  1 never executed
  1818     #####: 1238:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  1819 call    0 never executed
  1820     #####: 1239:            arrayNetSerialLevel2(r, (sArrayt *)(e->data), ctx, /*packed=*/true);
  1821 call    0 never executed
  1822         -: 1240:          }
  1823         -: 1241:        }}
  1824     #####: 1242:        break;
  1825         -: 1243:      case S_BYTES:
  1826     #####: 1244:        {forEachSDict(dict, e) {
  1827 branch  0 never executed
  1828 branch  1 never executed
  1829     #####: 1245:          if (e->key) {
  1830 branch  0 never executed
  1831 branch  1 never executed
  1832     #####: 1246:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  1833 call    0 never executed
  1834     #####: 1247:            B = (sBytest *)(e->data);
  1835     #####: 1248:            uintToVarint(r, B->count);
  1836 call    0 never executed
  1837     #####: 1249:            sBytesPushBuffer(r, &(B->data), B->count);
  1838 call    0 never executed
  1839         -: 1250:          }
  1840         -: 1251:        }}
  1841     #####: 1252:        break;
  1842         -: 1253:    }
  1843     #####: 1254:    ret;
  1844         -: 1255:  }
  1845         -: 1256:
  1846     #####: 1257:  if (packed) {
  1847 branch  0 never executed
  1848 branch  1 never executed
  1849     #####: 1258:    uintToVarint(r, dict->count);
  1850 call    0 never executed
  1851         -: 1259:  }
  1852         -: 1260:  else {
  1853     #####: 1261:    if (ctx->nibble == lowNbl) {
  1854 branch  0 never executed
  1855 branch  1 never executed
  1856     #####: 1262:      uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)dict->type], dict->count);
  1857 call    0 never executed
  1858         -: 1263:    }
  1859         -: 1264:    else {
  1860         -: 1265:      // high nibble
  1861         -: 1266:#define storeTypeInHighNbl(o)\
  1862         -: 1267:      ctx->nibble  = lowNbl;\
  1863         -: 1268:      data         = (char *)&((*r)->data) + ctx->nblOffset;\
  1864         -: 1269:      *data       |= NET_SERIAL_TYPES[(u8)o->type] << 4
  1865     #####: 1270:      storeTypeInHighNbl(dict);
  1866     #####: 1271:      uintToVarint(r, dict->count);
  1867 call    0 never executed
  1868         -: 1272:    }
  1869         -: 1273:  }
  1870         -: 1274:
  1871     #####: 1275:  forEachSDict(dict, e) {
  1872 branch  0 never executed
  1873 branch  1 never executed
  1874     #####: 1276:    if (e->key) {
  1875 branch  0 never executed
  1876 branch  1 never executed
  1877     #####: 1277:      sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  1878 call    0 never executed
  1879         -: 1278:
  1880     #####: 1279:      switch(e->data->type) {
  1881 branch  0 never executed
  1882 branch  1 never executed
  1883 branch  2 never executed
  1884 branch  3 never executed
  1885 branch  4 never executed
  1886 branch  5 never executed
  1887 branch  6 never executed
  1888 branch  7 never executed
  1889 branch  8 never executed
  1890         -: 1280:        case UNDEFINED:
  1891         -: 1281:        case CONTAINER:
  1892     #####: 1282:          if (ctx->nibble == lowNbl) {
  1893 branch  0 never executed
  1894 branch  1 never executed
  1895         -: 1283:            #define storeTypeOnly(o)\
  1896         -: 1284:            sBytesPush(r, NET_SERIAL_TYPES[(u8)o->type]);\
  1897         -: 1285:            ctx->nibble    = highNbl;\
  1898         -: 1286:            ctx->nblOffset = (*r)->count -1
  1899     #####: 1287:            storeTypeOnly(e->data);
  1900 call    0 never executed
  1901         -: 1288:          }
  1902         -: 1289:          else {
  1903     #####: 1290:            storeTypeInHighNbl(e->data);
  1904         -: 1291:          }
  1905     #####: 1292:          break;
  1906         -: 1293:        case BOOL:
  1907     #####: 1294:          if (!ctx->boolOffset) {
  1908 branch  0 never executed
  1909 branch  1 never executed
  1910         -: 1295:            // new packed bools
  1911     #####: 1296:            if (ctx->nibble == lowNbl) {
  1912 branch  0 never executed
  1913 branch  1 never executed
  1914         -: 1297:              #define storeNew4bPackedBool(o)\
  1915         -: 1298:              u8 c = NET_SERIAL_TYPES[(u8)o->type];\
  1916         -: 1299:              /* set bit 4 when true */\
  1917         -: 1300:              if (((sBoolt *)(o))->value)\
  1918         -: 1301:                c |= (1<<4);\
  1919         -: 1302:              sBytesPush(r, c);\
  1920         -: 1303:              ctx->boolShift  = 5;\
  1921         -: 1304:              ctx->boolOffset = (*r)->count -1
  1922     #####: 1305:              storeNew4bPackedBool(e->data);
  1923 branch  0 never executed
  1924 branch  1 never executed
  1925 call    2 never executed
  1926         -: 1306:            }
  1927         -: 1307:            else {
  1928         -: 1308:              // high nibble, next byte is packed bools
  1929     #####: 1309:              storeTypeInHighNbl(e->data);
  1930         -: 1310:              #define storeNew8bPackedBool(o)\
  1931         -: 1311:              u8 c         = 0;\
  1932         -: 1312:              if (((sBoolt *)(o))->value)\
  1933         -: 1313:                c = 1;\
  1934         -: 1314:              sBytesPush(r, c);\
  1935         -: 1315:              ctx->boolShift  = 1;\
  1936         -: 1316:              ctx->boolOffset = (*r)->count -1
  1937     #####: 1317:              storeNew8bPackedBool(e->data);
  1938 branch  0 never executed
  1939 branch  1 never executed
  1940 call    2 never executed
  1941         -: 1318:            }
  1942         -: 1319:          }
  1943         -: 1320:          else {
  1944         -: 1321:            // there was a bool before this one, fill bits in nibbles
  1945     #####: 1322:            if (ctx->nibble == lowNbl) {
  1946 branch  0 never executed
  1947 branch  1 never executed
  1948     #####: 1323:              if (ctx->boolShift == 8) {
  1949 branch  0 never executed
  1950 branch  1 never executed
  1951         -: 1324:                // previous packed bool is full
  1952         -: 1325:                // this byte is the new packed bools
  1953     #####: 1326:                storeNew4bPackedBool(e->data);
  1954 branch  0 never executed
  1955 branch  1 never executed
  1956 call    2 never executed
  1957         -: 1327:              }
  1958         -: 1328:              else {
  1959     #####: 1329:                storeTypeOnly(e->data);
  1960 call    0 never executed
  1961         -: 1330:                #define storeBool(o)\
  1962         -: 1331:                data           = (char *)&((*r)->data) + ctx->boolOffset;\
  1963         -: 1332:                if (((sBoolt *)(o))->value)\
  1964         -: 1333:                  *data |= 1 << ctx->boolShift;\
  1965         -: 1334:                ctx->boolShift++
  1966     #####: 1335:                storeBool(e->data);
  1967 branch  0 never executed
  1968 branch  1 never executed
  1969         -: 1336:              }
  1970         -: 1337:            }
  1971         -: 1338:            else {
  1972         -: 1339:              // high nibble
  1973     #####: 1340:              storeTypeInHighNbl(e->data);
  1974     #####: 1341:              if (ctx->boolShift == 8) {
  1975 branch  0 never executed
  1976 branch  1 never executed
  1977         -: 1342:                // previous packed bool is full
  1978         -: 1343:                // next byte is the new packed bools
  1979     #####: 1344:                storeNew8bPackedBool(e->data);
  1980 branch  0 never executed
  1981 branch  1 never executed
  1982 call    2 never executed
  1983         -: 1345:              }
  1984         -: 1346:              else {
  1985     #####: 1347:                storeBool(e->data);
  1986 branch  0 never executed
  1987 branch  1 never executed
  1988         -: 1348:              }
  1989         -: 1349:            }
  1990         -: 1350:          }
  1991     #####: 1351:          break;
  1992         -: 1352:        case DICT:
  1993     #####: 1353:          dictNetSerialLevel2(r, (sDictt *)(e->data), ctx, /*packed=*/false);
  1994 call    0 never executed
  1995     #####: 1354:          break;
  1996         -: 1355:        case DOUBLE:
  1997     #####: 1356:          if (ctx->nibble == lowNbl) {
  1998 branch  0 never executed
  1999 branch  1 never executed
  2000     #####: 1357:            storeTypeOnly(e->data);
  2001 call    0 never executed
  2002         -: 1358:          }
  2003         -: 1359:          else {
  2004         -: 1360:            // high nibble
  2005     #####: 1361:            storeTypeInHighNbl(e->data);
  2006         -: 1362:          }
  2007     #####: 1363:          sBytesPushBuffer(r, &((sDoublet *)(e->data))->value, sizeof(double));
  2008 call    0 never executed
  2009     #####: 1364:          break;
  2010         -: 1365:        case INT: {
  2011         -: 1366:            // encode int to varint
  2012         -: 1367:            // v is int64_t to convert to varint
  2013     #####: 1368:            i64 v = ((sIntt *)(e->data))->value;
  2014     #####: 1369:            if (ctx->nibble == lowNbl) {
  2015 branch  0 never executed
  2016 branch  1 never executed
  2017         -: 1370:              // encode v with arithmetic shifts
  2018     #####: 1371:              uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->data->type], (v << 1) ^ (v >> 63));
  2019 call    0 never executed
  2020         -: 1372:            }
  2021         -: 1373:            else {
  2022         -: 1374:              // high nibble
  2023     #####: 1375:              storeTypeInHighNbl(e->data);
  2024     #####: 1376:              uintToVarint(r, (v << 1) ^ (v >> 63));
  2025 call    0 never executed
  2026         -: 1377:            }
  2027         -: 1378:          }
  2028     #####: 1379:          break;
  2029         -: 1380:        case STRING:
  2030     #####: 1381:          if (ctx->nibble == lowNbl) {
  2031 branch  0 never executed
  2032 branch  1 never executed
  2033     #####: 1382:            storeTypeOnly(e->data);
  2034 call    0 never executed
  2035         -: 1383:          }
  2036         -: 1384:          else {
  2037         -: 1385:            // high nibble
  2038     #####: 1386:            storeTypeInHighNbl(e->data);
  2039         -: 1387:          }
  2040     #####: 1388:          sBytesPushBuffer(r, &((sStringt *)(e->data))->data, sizeof(sStringt) + strlen(&(((sStringt *)(e->data))->data)) -1);
  2041 call    0 never executed
  2042     #####: 1389:          break;
  2043         -: 1390:        case ARRAY:
  2044     #####: 1391:          arrayNetSerialLevel2(r, (sArrayt *)(e->data), ctx, /*packed=*/false);
  2045 call    0 never executed
  2046     #####: 1392:          break;
  2047         -: 1393:        case BYTES:
  2048     #####: 1394:          B = (sBytest *)(e->data);
  2049     #####: 1395:          if (ctx->nibble == lowNbl) {
  2050 branch  0 never executed
  2051 branch  1 never executed
  2052     #####: 1396:            uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->data->type], B->count);
  2053 call    0 never executed
  2054         -: 1397:          }
  2055         -: 1398:          else {
  2056         -: 1399:            // high nibble
  2057     #####: 1400:            storeTypeInHighNbl(e->data);
  2058     #####: 1401:            uintToVarint(r, B->count);
  2059 call    0 never executed
  2060         -: 1402:          }
  2061     #####: 1403:          sBytesPushBuffer(r, &(B->data), B->count);
  2062 call    0 never executed
  2063     #####: 1404:          break;
  2064         -: 1405:      }
  2065         -: 1406:    }
  2066         -: 1407:  }
  2067     #####: 1408:  ret;
  2068         -: 1409:}
  2069         -: 1410:
  2070         -: 1411:/**
  2071         -: 1412: * serialize array
  2072         -: 1413: *
  2073         -: 1414: * the serialized array is pushed to r.
  2074         -: 1415: * All elements are serialized recursively
  2075         -: 1416: *
  2076         -: 1417: * the data in containers is not serialized
  2077         -: 1418: *
  2078         -: 1419: * \param
  2079         -: 1420: *   r small bytes object
  2080         -: 1421: *   array to serialize
  2081         -: 1422: */
  2082 function arrayNetSerialLevel2 called 0 returned 0% blocks executed 0%
  2083     #####: 1423:internal void arrayNetSerialLevel2(sBytest **r, sArrayt *array, contextt *ctx, bool packed) {
  2084     #####: 1424:  sBytest *B     = NULL;
  2085     #####: 1425:  char    *data  = NULL;
  2086         -: 1426:
  2087         -: 1427:  // check if all elements have same type
  2088     #####: 1428:  bool allElementsHaveSameType = true;
  2089     #####: 1429:  bool foundFirstType          = false;
  2090     #####: 1430:  char type                    = 0;
  2091         -: 1431:
  2092     #####: 1432:  {forEachSArray(array, e) {
  2093 branch  0 never executed
  2094 branch  1 never executed
  2095     #####: 1433:    if (!e) {
  2096 branch  0 never executed
  2097 branch  1 never executed
  2098     #####: 1434:      if (foundFirstType) {
  2099 branch  0 never executed
  2100 branch  1 never executed
  2101     #####: 1435:        if (type != S_UNDEFINED) {
  2102 branch  0 never executed
  2103 branch  1 never executed
  2104     #####: 1436:          allElementsHaveSameType = false;
  2105     #####: 1437:          break;
  2106         -: 1438:        }
  2107         -: 1439:      }
  2108         -: 1440:      else {
  2109     #####: 1441:        type = S_UNDEFINED;
  2110     #####: 1442:        foundFirstType = true;
  2111         -: 1443:      }
  2112         -: 1444:    }
  2113         -: 1445:    else {
  2114     #####: 1446:      if (foundFirstType) {
  2115 branch  0 never executed
  2116 branch  1 never executed
  2117         -: 1447:        u8 nextType;
  2118     #####: 1448:        switch(e->type) {
  2119 branch  0 never executed
  2120 branch  1 never executed
  2121 branch  2 never executed
  2122         -: 1449:          case DICT:
  2123     #####: 1450:            nextType = isDictUniform((sDictt*)e);
  2124 call    0 never executed
  2125     #####: 1451:            break;
  2126         -: 1452:          case ARRAY:
  2127     #####: 1453:            nextType = isArrayUniform((sArrayt*)e);
  2128 call    0 never executed
  2129     #####: 1454:            break;
  2130         -: 1455:          default:
  2131     #####: 1456:            nextType = NET_SERIAL_TYPES[(u8)e->type];
  2132         -: 1457:        }
  2133     #####: 1458:        if (nextType != type) {
  2134 branch  0 never executed
  2135 branch  1 never executed
  2136     #####: 1459:          allElementsHaveSameType = false;
  2137     #####: 1460:          break;
  2138         -: 1461:        }
  2139         -: 1462:      }
  2140         -: 1463:      else {
  2141     #####: 1464:        switch(e->type) {
  2142 branch  0 never executed
  2143 branch  1 never executed
  2144 branch  2 never executed
  2145         -: 1465:          case DICT:
  2146     #####: 1466:            type = isDictUniform((sDictt*)e);
  2147 call    0 never executed
  2148     #####: 1467:            break;
  2149         -: 1468:          case ARRAY:
  2150     #####: 1469:            type = isArrayUniform((sArrayt*)e);
  2151 call    0 never executed
  2152     #####: 1470:            break;
  2153         -: 1471:          default:
  2154     #####: 1472:            type = NET_SERIAL_TYPES[(u8)e->type];
  2155         -: 1473:        }
  2156     #####: 1474:        foundFirstType = true;
  2157         -: 1475:      }
  2158         -: 1476:    }
  2159         -: 1477:  }}
  2160         -: 1478:
  2161     #####: 1479:  if (allElementsHaveSameType) {
  2162 branch  0 never executed
  2163 branch  1 never executed
  2164         -: 1480:    // pack array
  2165     #####: 1481:    if (packed) {
  2166 branch  0 never executed
  2167 branch  1 never executed
  2168     #####: 1482:      uintToNetTypeVarint(r, type, array->count);
  2169 call    0 never executed
  2170         -: 1483:    }
  2171         -: 1484:    else {
  2172     #####: 1485:      if (ctx->nibble == lowNbl) {
  2173 branch  0 never executed
  2174 branch  1 never executed
  2175     #####: 1486:        sBytesPush(r, (type << 4) + UNIFORM_ARRAY);
  2176 call    0 never executed
  2177     #####: 1487:        uintToVarint(r, array->count);
  2178 call    0 never executed
  2179         -: 1488:      }
  2180         -: 1489:      else {
  2181         -: 1490:        // high nibble
  2182     #####: 1491:        ctx->nibble  = lowNbl;
  2183     #####: 1492:        data         = (char *)&((*r)->data) + ctx->nblOffset;
  2184     #####: 1493:        *data       |= UNIFORM_ARRAY << 4;
  2185     #####: 1494:        uintToNetTypeVarint(r, type, array->count);
  2186 call    0 never executed
  2187         -: 1495:      }
  2188         -: 1496:    }
  2189         -: 1497:
  2190     #####: 1498:    switch(type) {
  2191 branch  0 never executed
  2192 branch  1 never executed
  2193 branch  2 never executed
  2194 branch  3 never executed
  2195 branch  4 never executed
  2196 branch  5 never executed
  2197 branch  6 never executed
  2198 branch  7 never executed
  2199         -: 1499:      case S_BOOL:
  2200     #####: 1500:        {forEachSArray(array, e) {
  2201 branch  0 never executed
  2202 branch  1 never executed
  2203     #####: 1501:          if (!ctx->boolOffset) {
  2204 branch  0 never executed
  2205 branch  1 never executed
  2206         -: 1502:            // new packed bools
  2207     #####: 1503:            storeNew8bPackedBool(e);
  2208 branch  0 never executed
  2209 branch  1 never executed
  2210 call    2 never executed
  2211         -: 1504:          }
  2212         -: 1505:          else {
  2213         -: 1506:            // there was a bool before this one, fill bits in nibbles
  2214     #####: 1507:            if (ctx->boolShift == 8) {
  2215 branch  0 never executed
  2216 branch  1 never executed
  2217         -: 1508:              // previous packed bool is full
  2218         -: 1509:              // next byte is the new packed bools
  2219     #####: 1510:              storeNew8bPackedBool(e);
  2220 branch  0 never executed
  2221 branch  1 never executed
  2222 call    2 never executed
  2223         -: 1511:            }
  2224         -: 1512:            else {
  2225     #####: 1513:              storeBool(e);
  2226 branch  0 never executed
  2227 branch  1 never executed
  2228         -: 1514:            }
  2229         -: 1515:          }
  2230         -: 1516:        }}
  2231     #####: 1517:        break;
  2232         -: 1518:      case S_DICT:
  2233         -: 1519:      case UNIFORM_DICT:
  2234     #####: 1520:        {forEachSArray(array, e) {
  2235 branch  0 never executed
  2236 branch  1 never executed
  2237     #####: 1521:          dictNetSerialLevel2(r, (sDictt *)e, ctx, /*packed=*/true);
  2238 call    0 never executed
  2239         -: 1522:        }}
  2240     #####: 1523:        break;
  2241         -: 1524:      case S_DOUBLE:
  2242     #####: 1525:        {forEachSArray(array, e) {
  2243 branch  0 never executed
  2244 branch  1 never executed
  2245     #####: 1526:          sBytesPushBuffer(r, &((sDoublet *)e)->value, sizeof(double));
  2246 call    0 never executed
  2247         -: 1527:        }}
  2248     #####: 1528:        break;
  2249         -: 1529:      case S_INT:
  2250     #####: 1530:        {forEachSArray(array, e) {
  2251 branch  0 never executed
  2252 branch  1 never executed
  2253     #####: 1531:          i64 v = ((sIntt *)e)->value;
  2254     #####: 1532:          uintToVarint(r, (v << 1) ^ (v >> 63));
  2255 call    0 never executed
  2256         -: 1533:        }}
  2257     #####: 1534:        break;
  2258         -: 1535:      case S_STRING:
  2259     #####: 1536:        {forEachSArray(array, e) {
  2260 branch  0 never executed
  2261 branch  1 never executed
  2262     #####: 1537:          sBytesPushBuffer(r, &((sStringt *)e)->data, sizeof(sStringt) + strlen(&(((sStringt *)e)->data)) -1);
  2263 call    0 never executed
  2264         -: 1538:        }}
  2265     #####: 1539:        break;
  2266         -: 1540:      case S_ARRAY:
  2267         -: 1541:      case UNIFORM_ARRAY:
  2268     #####: 1542:        {forEachSArray(array, e) {
  2269 branch  0 never executed
  2270 branch  1 never executed
  2271     #####: 1543:          arrayNetSerialLevel2(r, (sArrayt *)e, ctx, /*packed=*/true);
  2272 call    0 never executed
  2273         -: 1544:        }}
  2274     #####: 1545:        break;
  2275         -: 1546:      case S_BYTES:
  2276     #####: 1547:        {forEachSArray(array, e) {
  2277 branch  0 never executed
  2278 branch  1 never executed
  2279     #####: 1548:          B = (sBytest *)e;
  2280     #####: 1549:          uintToVarint(r, B->count);
  2281 call    0 never executed
  2282     #####: 1550:          sBytesPushBuffer(r, &(B->data), B->count);
  2283 call    0 never executed
  2284         -: 1551:        }}
  2285     #####: 1552:        break;
  2286         -: 1553:    }
  2287     #####: 1554:    ret;
  2288         -: 1555:  }
  2289         -: 1556:
  2290     #####: 1557:  if (packed) {
  2291 branch  0 never executed
  2292 branch  1 never executed
  2293     #####: 1558:    uintToVarint(r, array->count);
  2294 call    0 never executed
  2295         -: 1559:  }
  2296         -: 1560:  else {
  2297     #####: 1561:    if (ctx->nibble == lowNbl) {
  2298 branch  0 never executed
  2299 branch  1 never executed
  2300     #####: 1562:      uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)array->type], array->count);
  2301 call    0 never executed
  2302         -: 1563:    }
  2303         -: 1564:    else {
  2304         -: 1565:      // high nibble
  2305     #####: 1566:      storeTypeInHighNbl(array);
  2306     #####: 1567:      uintToVarint(r, array->count);
  2307 call    0 never executed
  2308         -: 1568:    }
  2309         -: 1569:  }
  2310         -: 1570:
  2311     #####: 1571:  forEachSArray(array, e) {
  2312 branch  0 never executed
  2313 branch  1 never executed
  2314     #####: 1572:    if (!e) {
  2315 branch  0 never executed
  2316 branch  1 never executed
  2317         -: 1573:      // empty slots are represented as undefined elements
  2318     #####: 1574:      if (ctx->nibble == lowNbl) {
  2319 branch  0 never executed
  2320 branch  1 never executed
  2321     #####: 1575:        sBytesPush(r, NET_SERIAL_TYPES[UNDEFINED]);
  2322 call    0 never executed
  2323     #####: 1576:        ctx->nibble    = highNbl;
  2324     #####: 1577:        ctx->nblOffset = (*r)->count -1;
  2325         -: 1578:      }
  2326         -: 1579:      else {
  2327         -: 1580:        // high nibble
  2328     #####: 1581:        ctx->nibble  = lowNbl;
  2329     #####: 1582:        data         = (char *)&((*r)->data) + ctx->nblOffset;
  2330     #####: 1583:        *data       |= NET_SERIAL_TYPES[UNDEFINED] << 4;
  2331         -: 1584:      }
  2332         -: 1585:    }
  2333         -: 1586:    else {
  2334     #####: 1587:      switch(e->type) {
  2335 branch  0 never executed
  2336 branch  1 never executed
  2337 branch  2 never executed
  2338 branch  3 never executed
  2339 branch  4 never executed
  2340 branch  5 never executed
  2341 branch  6 never executed
  2342 branch  7 never executed
  2343 branch  8 never executed
  2344         -: 1588:        case UNDEFINED:
  2345         -: 1589:        case CONTAINER:
  2346     #####: 1590:          if (ctx->nibble == lowNbl) {
  2347 branch  0 never executed
  2348 branch  1 never executed
  2349     #####: 1591:            storeTypeOnly(e);
  2350 call    0 never executed
  2351         -: 1592:          }
  2352         -: 1593:          else {
  2353         -: 1594:            // high nibble
  2354     #####: 1595:            storeTypeInHighNbl(e);
  2355         -: 1596:          }
  2356     #####: 1597:          break;
  2357         -: 1598:        case BOOL:
  2358     #####: 1599:          if (!ctx->boolOffset) {
  2359 branch  0 never executed
  2360 branch  1 never executed
  2361         -: 1600:            // new packed bools
  2362     #####: 1601:            if (ctx->nibble == lowNbl) {
  2363 branch  0 never executed
  2364 branch  1 never executed
  2365     #####: 1602:              storeNew4bPackedBool(e);
  2366 branch  0 never executed
  2367 branch  1 never executed
  2368 call    2 never executed
  2369         -: 1603:            }
  2370         -: 1604:            else {
  2371         -: 1605:              // high nibble, next byte is packed bools
  2372     #####: 1606:              storeTypeInHighNbl(e);
  2373     #####: 1607:              storeNew8bPackedBool(e);
  2374 branch  0 never executed
  2375 branch  1 never executed
  2376 call    2 never executed
  2377         -: 1608:            }
  2378         -: 1609:          }
  2379         -: 1610:          else {
  2380         -: 1611:            // there was a bool before this one, fill bits in nibbles
  2381     #####: 1612:            if (ctx->nibble == lowNbl) {
  2382 branch  0 never executed
  2383 branch  1 never executed
  2384     #####: 1613:              if (ctx->boolShift == 8) {
  2385 branch  0 never executed
  2386 branch  1 never executed
  2387         -: 1614:                // previous packed bool is full
  2388         -: 1615:                // this byte is the new packed bools
  2389     #####: 1616:                storeNew4bPackedBool(e);
  2390 branch  0 never executed
  2391 branch  1 never executed
  2392 call    2 never executed
  2393         -: 1617:              }
  2394         -: 1618:              else {
  2395     #####: 1619:                storeTypeOnly(e);
  2396 call    0 never executed
  2397     #####: 1620:                storeBool(e);
  2398 branch  0 never executed
  2399 branch  1 never executed
  2400         -: 1621:              }
  2401         -: 1622:            }
  2402         -: 1623:            else {
  2403         -: 1624:              // high nibble
  2404     #####: 1625:              storeTypeInHighNbl(e);
  2405     #####: 1626:              if (ctx->boolShift == 8) {
  2406 branch  0 never executed
  2407 branch  1 never executed
  2408         -: 1627:                // previous packed bool is full
  2409         -: 1628:                // next byte is the new packed bools
  2410     #####: 1629:                storeNew8bPackedBool(e);
  2411 branch  0 never executed
  2412 branch  1 never executed
  2413 call    2 never executed
  2414         -: 1630:              }
  2415         -: 1631:              else {
  2416     #####: 1632:                storeBool(e);
  2417 branch  0 never executed
  2418 branch  1 never executed
  2419         -: 1633:              }
  2420         -: 1634:            }
  2421         -: 1635:          }
  2422     #####: 1636:          break;
  2423         -: 1637:        case DICT:
  2424     #####: 1638:          dictNetSerialLevel2(r, (sDictt *)e, ctx, /*packed=*/false);
  2425 call    0 never executed
  2426     #####: 1639:          break;
  2427         -: 1640:        case DOUBLE:
  2428     #####: 1641:          if (ctx->nibble == lowNbl) {
  2429 branch  0 never executed
  2430 branch  1 never executed
  2431     #####: 1642:            storeTypeOnly(e);
  2432 call    0 never executed
  2433         -: 1643:          }
  2434         -: 1644:          else {
  2435         -: 1645:            // high nibble
  2436     #####: 1646:            storeTypeInHighNbl(e);
  2437         -: 1647:          }
  2438     #####: 1648:          sBytesPushBuffer(r, &((sDoublet *)e)->value, sizeof(double));
  2439 call    0 never executed
  2440     #####: 1649:          break;
  2441         -: 1650:        case INT: {
  2442         -: 1651:            // encode int to varint
  2443         -: 1652:            // v is int64_t to convert to varint
  2444     #####: 1653:            i64 v = ((sIntt *)&(e->type))->value;
  2445     #####: 1654:            if (ctx->nibble == lowNbl) {
  2446 branch  0 never executed
  2447 branch  1 never executed
  2448         -: 1655:              // encode v with arithmetic shifts
  2449     #####: 1656:              uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->type], (v << 1) ^ (v >> 63));
  2450 call    0 never executed
  2451         -: 1657:            }
  2452         -: 1658:            else {
  2453         -: 1659:              // high nibble
  2454     #####: 1660:              storeTypeInHighNbl(e);
  2455     #####: 1661:              uintToVarint(r, (v << 1) ^ (v >> 63));
  2456 call    0 never executed
  2457         -: 1662:            }
  2458         -: 1663:          }
  2459     #####: 1664:          break;
  2460         -: 1665:        case STRING:
  2461     #####: 1666:          if (ctx->nibble == lowNbl) {
  2462 branch  0 never executed
  2463 branch  1 never executed
  2464     #####: 1667:            storeTypeOnly(e);
  2465 call    0 never executed
  2466         -: 1668:          }
  2467         -: 1669:          else {
  2468         -: 1670:            // high nibble
  2469     #####: 1671:            storeTypeInHighNbl(e);
  2470         -: 1672:          }
  2471     #####: 1673:          sBytesPushBuffer(r, &((sStringt *)e)->data, sizeof(sStringt) + strlen(&(((sStringt *)e)->data)) -1);
  2472 call    0 never executed
  2473     #####: 1674:          break;
  2474         -: 1675:        case ARRAY:
  2475     #####: 1676:          arrayNetSerialLevel2(r, (sArrayt *)e, ctx, /*packed=*/false);
  2476 call    0 never executed
  2477     #####: 1677:          break;
  2478         -: 1678:        case BYTES:
  2479     #####: 1679:          B = (sBytest *)e;
  2480     #####: 1680:          if (ctx->nibble == lowNbl) {
  2481 branch  0 never executed
  2482 branch  1 never executed
  2483     #####: 1681:            uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->type], B->count);
  2484 call    0 never executed
  2485         -: 1682:          }
  2486         -: 1683:          else {
  2487         -: 1684:            // high nibble
  2488     #####: 1685:            storeTypeInHighNbl(e);
  2489     #####: 1686:            uintToVarint(r, B->count);
  2490 call    0 never executed
  2491         -: 1687:          }
  2492     #####: 1688:          sBytesPushBuffer(r, &(B->data), B->count);
  2493 call    0 never executed
  2494     #####: 1689:          break;
  2495         -: 1690:      }
  2496         -: 1691:    }
  2497         -: 1692:  }
  2498     #####: 1693:  ret;
  2499         -: 1694:}
  2500         -: 1695:
  2501 function serialNetSerialLevel2 called 0 returned 0% blocks executed 0%
  2502     #####: 1696:internal smallBytest* serialNetSerialLevel2(smallJsont *self) {
  2503         -: 1697:
  2504     #####: 1698:  smallt *o = getsoG(self);
  2505 call    0 never executed
  2506         -: 1699:
  2507     #####: 1700:  if (o == NULL)
  2508 branch  0 never executed
  2509 branch  1 never executed
  2510     #####: 1701:    ret NULL;
  2511         -: 1702:
  2512     #####: 1703:  sBytest *B = netSerialLevel2(o);
  2513 call    0 never executed
  2514         -: 1704:
  2515     #####: 1705:  if (!B) {
  2516 branch  0 never executed
  2517 branch  1 never executed
  2518     #####: 1706:    ret NULL;
  2519         -: 1707:  }
  2520         -: 1708:
  2521     #####: 1709:  createAllocateSmallBytes(r);
  2522 call    0 never executed
  2523     #####: 1710:  r->B = B;
  2524     #####: 1711:  ret r;
  2525         -: 1712:}
  2526         -: 1713:
  2527         -: 1714:// level 3
  2528         -: 1715:// like level 2, elements of identical type in a row are packed
  2529         -: 1716:
  2530         -: 1717:/**
  2531         -: 1718: * serializer top function
  2532         -: 1719: */
  2533 function netSerial called 86 returned 100% blocks executed 88%
  2534        86: 1720:internal sBytest* netSerial(smallt *o) {
  2535        86: 1721:  sBytest *r = NULL;
  2536        86: 1722:  sBytest *B = NULL;
  2537        86: 1723:  contextt ctx = {.nibble=lowNbl, .nblOffset=0, .boolShift = 0, .boolOffset=0};
  2538         -: 1724:
  2539        86: 1725:  switch(o->type) {
  2540 branch  0 taken 1%
  2541 branch  1 taken 1%
  2542 branch  2 taken 47%
  2543 branch  3 taken 1%
  2544 branch  4 taken 3%
  2545 branch  5 taken 1%
  2546 branch  6 taken 45%
  2547 branch  7 taken 0%
  2548 branch  8 taken 0%
  2549         -: 1726:    case UNDEFINED:
  2550         -: 1727:    case CONTAINER:
  2551         1: 1728:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
  2552 call    0 returned 100%
  2553         1: 1729:      break;
  2554         -: 1730:    case BOOL: {
  2555         1: 1731:      u8 c = NET_SERIAL_TYPES[(u8)o->type];
  2556         -: 1732:      // set bit 4 when true
  2557         1: 1733:      if (((sBoolt *)&(o->type))->value)
  2558 branch  0 taken 100% (fallthrough)
  2559 branch  1 taken 0%
  2560         1: 1734:        c |= (1<<4);
  2561         1: 1735:      sBytesPush(&r, c);
  2562 call    0 returned 100%
  2563         -: 1736:      }
  2564         1: 1737:      break;
  2565         -: 1738:    case DICT:
  2566        40: 1739:      dictNetSerial(&r, (sDictt *)&(o->type), &ctx, /*packing=*/NOPACKING);
  2567 call    0 returned 100%
  2568        40: 1740:      break;
  2569         -: 1741:    case DOUBLE:
  2570         1: 1742:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
  2571 call    0 returned 100%
  2572         1: 1743:      sBytesPushBuffer(&r, &((sDoublet *)&(o->type))->value, sizeof(double));
  2573 call    0 returned 100%
  2574         1: 1744:      break;
  2575         -: 1745:    case INT: {
  2576         -: 1746:      // encode int to varint
  2577         -: 1747:      // v is int64_t to convert to varint
  2578         3: 1748:      i64 v = ((sIntt *)&(o->type))->value;
  2579         -: 1749:      // encode v with arithmetic shifts
  2580         3: 1750:      uintToNetTypeVarint(&r, NET_SERIAL_TYPES[(u8)o->type], (v << 1) ^ (v >> 63));
  2581 call    0 returned 100%
  2582         -: 1751:      }
  2583         3: 1752:      break;
  2584         -: 1753:    case STRING:
  2585         1: 1754:      sBytesPush(&r, NET_SERIAL_TYPES[(u8)o->type]);
  2586 call    0 returned 100%
  2587         1: 1755:      sBytesPushBuffer(&r, &((sStringt *)&(o->type))->data, sizeof(sStringt) + strlen(&(((sStringt *)&(o->type))->data)) -1);
  2588 call    0 returned 100%
  2589         1: 1756:      break;
  2590         -: 1757:    case ARRAY:
  2591        39: 1758:      arrayNetSerial(&r, (sArrayt *)&(o->type), &ctx, /*packing=*/NOPACKING);
  2592 call    0 returned 100%
  2593        39: 1759:      break;
  2594         -: 1760:    case BYTES:
  2595     #####: 1761:      B = (sBytest *)&(o->type);
  2596     #####: 1762:      uintToNetTypeVarint(&r, NET_SERIAL_TYPES[(u8)o->type], B->count);
  2597 call    0 never executed
  2598     #####: 1763:      sBytesPushBuffer(&r, &(B->data), B->count);
  2599 call    0 never executed
  2600     #####: 1764:      break;
  2601         -: 1765:  }
  2602        86: 1766:  ret r;
  2603         -: 1767:}
  2604         -: 1768:
  2605         -: 1769:/**
  2606         -: 1770: * serialize dictionary
  2607         -: 1771: *
  2608         -: 1772: * the serialized dict is pushed to r.
  2609         -: 1773: * All elements are serialized recursively
  2610         -: 1774: *
  2611         -: 1775: * the data in containers is not serialized
  2612         -: 1776: *
  2613         -: 1777: * \param
  2614         -: 1778: *   r small bytes object
  2615         -: 1779: *   dict dictionary to serialize
  2616         -: 1780: */
  2617 function dictNetSerial called 83 returned 100% blocks executed 96%
  2618        83: 1781:internal void dictNetSerial(sBytest **r, sDictt *dict, contextt *ctx, packingT packing) {
  2619        83: 1782:  sBytest *B     = NULL;
  2620        83: 1783:  char    *data  = NULL;
  2621         -: 1784:
  2622         -: 1785:  // compute allocated element count and use that instead of dict->count
  2623         -: 1786:  // when elements are deleted, some positions are NULL
  2624         -: 1787:  // and should not be counted
  2625        83: 1788:  u32 cnt =0;
  2626       302: 1789:  {forEachSDict(dict, e) {
  2627 branch  0 taken 73%
  2628 branch  1 taken 27% (fallthrough)
  2629       219: 1790:    if (e->key) {
  2630 branch  0 taken 99% (fallthrough)
  2631 branch  1 taken 1%
  2632       218: 1791:      inc cnt;
  2633         -: 1792:    }
  2634         -: 1793:  }}
  2635         -: 1794:
  2636         -: 1795:  // check if all elements have same type
  2637         -: 1796:  // then set dict type normal or uniform
  2638         -: 1797:  // array and dict have to be checked recursively to know if they are normal or uniform
  2639        83: 1798:  bool allElementsHaveSameType = true;
  2640        83: 1799:  bool foundFirstType          = false;
  2641        83: 1800:  char type                    = 0;
  2642         -: 1801:  // get first element type
  2643         -: 1802:  // compare to other element type
  2644       209: 1803:  {forEachSDict(dict, e) {
  2645 branch  0 taken 78%
  2646 branch  1 taken 22% (fallthrough)
  2647       164: 1804:    if (e->key) {
  2648 branch  0 taken 99% (fallthrough)
  2649 branch  1 taken 1%
  2650       163: 1805:      if (foundFirstType) {
  2651 branch  0 taken 56% (fallthrough)
  2652 branch  1 taken 44%
  2653         -: 1806:        u8 nextType;
  2654        92: 1807:        switch(e->data->type) {
  2655 branch  0 taken 16%
  2656 branch  1 taken 11%
  2657 branch  2 taken 73%
  2658         -: 1808:          case DICT:
  2659        15: 1809:            nextType = isDictUniform((sDictt*)e->data);
  2660 call    0 returned 100%
  2661        15: 1810:            break;
  2662         -: 1811:          case ARRAY:
  2663        10: 1812:            nextType = isArrayUniform((sArrayt*)e->data);
  2664 call    0 returned 100%
  2665        10: 1813:            break;
  2666         -: 1814:          default:
  2667        67: 1815:            nextType = NET_SERIAL_TYPES[(u8)e->data->type];
  2668         -: 1816:        }
  2669        92: 1817:        if (nextType != type) {
  2670 branch  0 taken 41% (fallthrough)
  2671 branch  1 taken 59%
  2672        38: 1818:          allElementsHaveSameType = false;
  2673        38: 1819:          break;
  2674         -: 1820:        }
  2675         -: 1821:      }
  2676         -: 1822:      else {
  2677        71: 1823:        switch(e->data->type) {
  2678 branch  0 taken 7%
  2679 branch  1 taken 4%
  2680 branch  2 taken 89%
  2681         -: 1824:          case DICT:
  2682         5: 1825:            type = isDictUniform((sDictt*)e->data);
  2683 call    0 returned 100%
  2684         5: 1826:            break;
  2685         -: 1827:          case ARRAY:
  2686         3: 1828:            type = isArrayUniform((sArrayt*)e->data);
  2687 call    0 returned 100%
  2688         3: 1829:            break;
  2689         -: 1830:          default:
  2690        63: 1831:            type = NET_SERIAL_TYPES[(u8)e->data->type];
  2691         -: 1832:        }
  2692        71: 1833:        foundFirstType = true;
  2693         -: 1834:      }
  2694         -: 1835:    }
  2695         -: 1836:  }}
  2696         -: 1837:
  2697        83: 1838:  if (allElementsHaveSameType) {
  2698 branch  0 taken 54% (fallthrough)
  2699 branch  1 taken 46%
  2700         -: 1839:    // uniform dict
  2701         -: 1840:    // encode type and element count
  2702         -: 1841:
  2703         -: 1842:    // in pack dictionary
  2704        45: 1843:    if (packing == PACK) {
  2705 branch  0 taken 40% (fallthrough)
  2706 branch  1 taken 60%
  2707         -: 1844:      // uniform dict can't be packed
  2708         -: 1845:      // because there is only one type of packed arrays
  2709        18: 1846:      goto normalDict;
  2710         -: 1847:    }
  2711        27: 1848:    elif (packing == UNIFORM) {
  2712 branch  0 taken 15% (fallthrough)
  2713 branch  1 taken 85%
  2714         -: 1849:      // when the packing is uniform, there is no need to encode UNIFORM_DICT since all elements have this type
  2715         4: 1850:      uintToNetTypeVarint(r, type, cnt);
  2716 call    0 returned 100%
  2717         -: 1851:    }
  2718         -: 1852:    else {
  2719        23: 1853:      if (ctx->nibble == lowNbl) {
  2720 branch  0 taken 91% (fallthrough)
  2721 branch  1 taken 9%
  2722        21: 1854:        sBytesPush(r, (type << 4) + UNIFORM_DICT);
  2723 call    0 returned 100%
  2724        21: 1855:        uintToVarint(r, cnt);
  2725 call    0 returned 100%
  2726         -: 1856:      }
  2727         -: 1857:      else {
  2728         -: 1858:        // high nibble
  2729         2: 1859:        ctx->nibble  = lowNbl;
  2730         2: 1860:        data         = (char *)&((*r)->data) + ctx->nblOffset;
  2731         2: 1861:        *data       |= UNIFORM_DICT << 4;
  2732         2: 1862:        uintToNetTypeVarint(r, type, cnt);
  2733 call    0 returned 100%
  2734         -: 1863:      }
  2735         -: 1864:    }
  2736         -: 1865:
  2737         -: 1866:    // encode all element keys and values
  2738        27: 1867:    switch(type) {
  2739 branch  0 taken 11%
  2740 branch  1 taken 15%
  2741 branch  2 taken 7%
  2742 branch  3 taken 4%
  2743 branch  4 taken 33%
  2744 branch  5 taken 19%
  2745 branch  6 taken 7%
  2746 branch  7 taken 4%
  2747 branch  8 taken 0%
  2748         -: 1868:      case S_UNDEFINED:
  2749        10: 1869:        {forEachSDict(dict, e) {
  2750 branch  0 taken 70%
  2751 branch  1 taken 30% (fallthrough)
  2752         7: 1870:          if (e->key) {
  2753 branch  0 taken 86% (fallthrough)
  2754 branch  1 taken 14%
  2755         6: 1871:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  2756 call    0 returned 100%
  2757         -: 1872:          }
  2758         -: 1873:        }}
  2759         -: 1874:
  2760         3: 1875:        break;
  2761         -: 1876:      case S_BOOL:
  2762        19: 1877:        {forEachSDict(dict, e) {
  2763 branch  0 taken 79%
  2764 branch  1 taken 21% (fallthrough)
  2765        15: 1878:          if (e->key) {
  2766 branch  0 taken 100% (fallthrough)
  2767 branch  1 taken 0%
  2768        15: 1879:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  2769 call    0 returned 100%
  2770         -: 1880:
  2771        15: 1881:            if (!ctx->boolOffset) {
  2772 branch  0 taken 20% (fallthrough)
  2773 branch  1 taken 80%
  2774         -: 1882:              // new packed bools
  2775         3: 1883:              storeNew8bPackedBool(e->data);
  2776 branch  0 taken 100% (fallthrough)
  2777 branch  1 taken 0%
  2778 call    2 returned 100%
  2779         -: 1884:            }
  2780         -: 1885:            else {
  2781         -: 1886:              // there was a bool before this one, fill bits in nibbles
  2782        12: 1887:              if (ctx->boolShift == 8) {
  2783 branch  0 taken 8% (fallthrough)
  2784 branch  1 taken 92%
  2785         -: 1888:                // previous packed bool is full
  2786         -: 1889:                // next byte is the new packed bools
  2787         1: 1890:                storeNew8bPackedBool(e->data);
  2788 branch  0 taken 100% (fallthrough)
  2789 branch  1 taken 0%
  2790 call    2 returned 100%
  2791         -: 1891:              }
  2792         -: 1892:              else {
  2793        11: 1893:                storeBool(e->data);
  2794 branch  0 taken 91% (fallthrough)
  2795 branch  1 taken 9%
  2796         -: 1894:              }
  2797         -: 1895:            }
  2798         -: 1896:          }
  2799         -: 1897:        }}
  2800         4: 1898:        break;
  2801         -: 1899:      case S_DICT:
  2802         -: 1900:      case UNIFORM_DICT:
  2803         6: 1901:        {forEachSDict(dict, e) {
  2804 branch  0 taken 67%
  2805 branch  1 taken 33% (fallthrough)
  2806         4: 1902:          if (e->key) {
  2807 branch  0 taken 100% (fallthrough)
  2808 branch  1 taken 0%
  2809         4: 1903:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  2810 call    0 returned 100%
  2811         4: 1904:            dictNetSerial(r, (sDictt *)(e->data), ctx, /*packing=*/UNIFORM);
  2812 call    0 returned 100%
  2813         -: 1905:          }
  2814         -: 1906:        }}
  2815         2: 1907:        break;
  2816         -: 1908:      case S_DOUBLE:
  2817         4: 1909:        {forEachSDict(dict, e) {
  2818 branch  0 taken 75%
  2819 branch  1 taken 25% (fallthrough)
  2820         3: 1910:          if (e->key) {
  2821 branch  0 taken 100% (fallthrough)
  2822 branch  1 taken 0%
  2823         3: 1911:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  2824 call    0 returned 100%
  2825         3: 1912:            sBytesPushBuffer(r, &((sDoublet *)(e->data))->value, sizeof(double));
  2826 call    0 returned 100%
  2827         -: 1913:          }
  2828         -: 1914:        }}
  2829         1: 1915:        break;
  2830         -: 1916:      case S_INT:
  2831        21: 1917:        {forEachSDict(dict, e) {
  2832 branch  0 taken 57%
  2833 branch  1 taken 43% (fallthrough)
  2834        12: 1918:          if (e->key) {
  2835 branch  0 taken 100% (fallthrough)
  2836 branch  1 taken 0%
  2837        12: 1919:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  2838 call    0 returned 100%
  2839        12: 1920:            i64 v = ((sIntt *)(e->data))->value;
  2840        12: 1921:            uintToVarint(r, (v << 1) ^ (v >> 63));
  2841 call    0 returned 100%
  2842         -: 1922:          }
  2843         -: 1923:        }}
  2844         9: 1924:        break;
  2845         -: 1925:      case S_STRING:
  2846        16: 1926:        {forEachSDict(dict, e) {
  2847 branch  0 taken 69%
  2848 branch  1 taken 31% (fallthrough)
  2849        11: 1927:          if (e->key) {
  2850 branch  0 taken 100% (fallthrough)
  2851 branch  1 taken 0%
  2852        11: 1928:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  2853 call    0 returned 100%
  2854        11: 1929:            sBytesPushBuffer(r, &((sStringt *)(e->data))->data, sizeof(sStringt) + strlen(&(((sStringt *)(e->data))->data)) -1);
  2855 call    0 returned 100%
  2856         -: 1930:          }
  2857         -: 1931:        }}
  2858         5: 1932:        break;
  2859         -: 1933:      case S_ARRAY:
  2860         -: 1934:      case UNIFORM_ARRAY:
  2861         4: 1935:        {forEachSDict(dict, e) {
  2862 branch  0 taken 50%
  2863 branch  1 taken 50% (fallthrough)
  2864         2: 1936:          if (e->key) {
  2865 branch  0 taken 100% (fallthrough)
  2866 branch  1 taken 0%
  2867         2: 1937:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  2868 call    0 returned 100%
  2869         2: 1938:            arrayNetSerial(r, (sArrayt *)(e->data), ctx, /*packing=*/UNIFORM);
  2870 call    0 returned 100%
  2871         -: 1939:          }
  2872         -: 1940:        }}
  2873         2: 1941:        break;
  2874         -: 1942:      case S_BYTES:
  2875         3: 1943:        {forEachSDict(dict, e) {
  2876 branch  0 taken 67%
  2877 branch  1 taken 33% (fallthrough)
  2878         2: 1944:          if (e->key) {
  2879 branch  0 taken 100% (fallthrough)
  2880 branch  1 taken 0%
  2881         2: 1945:            sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  2882 call    0 returned 100%
  2883         2: 1946:            B = (sBytest *)(e->data);
  2884         2: 1947:            uintToVarint(r, B->count);
  2885 call    0 returned 100%
  2886         2: 1948:            sBytesPushBuffer(r, &(B->data), B->count);
  2887 call    0 returned 100%
  2888         -: 1949:          }
  2889         -: 1950:        }}
  2890         1: 1951:        break;
  2891         -: 1952:    }
  2892        27: 1953:    ret;
  2893         -: 1954:  }
  2894         -: 1955:
  2895         -: 1956:  normalDict:
  2896         -: 1957:  // encode type and element count
  2897        56: 1958:  if (packing == PACK or packing == UNIFORM) {
  2898 branch  0 taken 59% (fallthrough)
  2899 branch  1 taken 41%
  2900 branch  2 taken 12% (fallthrough)
  2901 branch  3 taken 88%
  2902         -: 1959:    // when the packing is packed or uniform, there is no need to encode DICT type since all elements have this type
  2903        27: 1960:    uintToVarint(r, cnt);
  2904 call    0 returned 100%
  2905         -: 1961:  }
  2906         -: 1962:  else {
  2907        29: 1963:    if (ctx->nibble == lowNbl) {
  2908 branch  0 taken 93% (fallthrough)
  2909 branch  1 taken 7%
  2910        27: 1964:      uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)dict->type], cnt);
  2911 call    0 returned 100%
  2912         -: 1965:    }
  2913         -: 1966:    else {
  2914         -: 1967:      // high nibble
  2915         -: 1968:      #define storeTypeInHighNbl(o)\
  2916         -: 1969:      ctx->nibble  = lowNbl;\
  2917         -: 1970:      data         = (char *)&((*r)->data) + ctx->nblOffset;\
  2918         -: 1971:      *data       |= NET_SERIAL_TYPES[(u8)o->type] << 4
  2919         2: 1972:      storeTypeInHighNbl(dict);
  2920         2: 1973:      uintToVarint(r, cnt);
  2921 call    0 returned 100%
  2922         -: 1974:    }
  2923         -: 1975:  }
  2924         -: 1976:
  2925        56: 1977:  bool   pack = false;
  2926         -: 1978:  size_t packCount;
  2927       219: 1979:  enumerateSDict(dict, e, eIdx) {
  2928 branch  0 taken 74%
  2929 branch  1 taken 26% (fallthrough)
  2930       163: 1980:    if (e->key) {
  2931 branch  0 taken 100% (fallthrough)
  2932 branch  1 taken 0%
  2933       163: 1981:      if (!pack) {
  2934 branch  0 taken 77% (fallthrough)
  2935 branch  1 taken 23%
  2936         -: 1982:        // scan dict for packing
  2937       125: 1983:        if ((cnt - eIdx) > 3) {
  2938 branch  0 taken 34% (fallthrough)
  2939 branch  1 taken 66%
  2940         -: 1984:          // at least 4 elements, less than that is not worth it
  2941        42: 1985:          if (   e->data->type == DICT
  2942 branch  0 taken 93% (fallthrough)
  2943 branch  1 taken 7%
  2944        39: 1986:              or e->data->type == DOUBLE
  2945 branch  0 taken 95% (fallthrough)
  2946 branch  1 taken 5%
  2947        37: 1987:              or e->data->type == INT
  2948 branch  0 taken 95% (fallthrough)
  2949 branch  1 taken 5%
  2950        35: 1988:              or e->data->type == STRING
  2951 branch  0 taken 94% (fallthrough)
  2952 branch  1 taken 6%
  2953        33: 1989:              or e->data->type == ARRAY
  2954 branch  0 taken 94% (fallthrough)
  2955 branch  1 taken 6%
  2956        31: 1990:              or e->data->type == BYTES) {
  2957 branch  0 taken 0% (fallthrough)
  2958 branch  1 taken 100%
  2959        11: 1991:            type      = e->data->type;
  2960        11: 1992:            packCount = 1;
  2961        11: 1993:            sDictElemt *element = &((dict)->elements) + eIdx +1;
  2962        49: 1994:            for (size_t i = eIdx+1; i < (dict)->count ; i++, element = &((dict)->elements) + i) {
  2963 branch  0 taken 100%
  2964 branch  1 taken 0% (fallthrough)
  2965        49: 1995:              if (element->key) {
  2966 branch  0 taken 100% (fallthrough)
  2967 branch  1 taken 0%
  2968        49: 1996:                if (element->data->type != type) {
  2969 branch  0 taken 22% (fallthrough)
  2970 branch  1 taken 78%
  2971        11: 1997:                  break;
  2972         -: 1998:                }
  2973        38: 1999:                packCount++;
  2974         -: 2000:              } // element->key
  2975         -: 2001:            } // for
  2976        11: 2002:            if (packCount > 3) {
  2977 branch  0 taken 100% (fallthrough)
  2978 branch  1 taken 0%
  2979        11: 2003:              type = PACKED_NET_SERIAL_TYPES[(u8)type];
  2980        11: 2004:              pack = true;
  2981         -: 2005:            }
  2982         -: 2006:          } // test current element type
  2983         -: 2007:        } // is dict big enough
  2984         -: 2008:      } // not already packing
  2985         -: 2009:
  2986         -: 2010:      // encode key
  2987       163: 2011:      sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
  2988 call    0 returned 100%
  2989         -: 2012:
  2990         -: 2013:      // encode value
  2991       163: 2014:      switch(e->data->type) {
  2992 branch  0 taken 18%
  2993 branch  1 taken 19%
  2994 branch  2 taken 12%
  2995 branch  3 taken 7%
  2996 branch  4 taken 20%
  2997 branch  5 taken 13%
  2998 branch  6 taken 9%
  2999 branch  7 taken 1%
  3000 branch  8 taken 0%
  3001         -: 2015:        case UNDEFINED:
  3002         -: 2016:        case CONTAINER:
  3003        29: 2017:          if (ctx->nibble == lowNbl) {
  3004 branch  0 taken 93% (fallthrough)
  3005 branch  1 taken 7%
  3006         -: 2018:            #define storeTypeOnly(o)\
  3007         -: 2019:            sBytesPush(r, NET_SERIAL_TYPES[(u8)o->type]);\
  3008         -: 2020:            ctx->nibble    = highNbl;\
  3009         -: 2021:            ctx->nblOffset = (*r)->count -1
  3010        27: 2022:            storeTypeOnly(e->data);
  3011 call    0 returned 100%
  3012         -: 2023:          }
  3013         -: 2024:          else {
  3014         2: 2025:            storeTypeInHighNbl(e->data);
  3015         -: 2026:          }
  3016        29: 2027:          break;
  3017         -: 2028:        case BOOL:
  3018        31: 2029:          if (!ctx->boolOffset) {
  3019 branch  0 taken 16% (fallthrough)
  3020 branch  1 taken 84%
  3021         -: 2030:            // new packed bools
  3022         5: 2031:            if (ctx->nibble == lowNbl) {
  3023 branch  0 taken 60% (fallthrough)
  3024 branch  1 taken 40%
  3025         -: 2032:              #define storeNew4bPackedBool(o)\
  3026         -: 2033:              u8 c = NET_SERIAL_TYPES[(u8)o->type];\
  3027         -: 2034:              /* set bit 4 when true */\
  3028         -: 2035:              if (((sBoolt *)(o))->value)\
  3029         -: 2036:                c |= (1<<4);\
  3030         -: 2037:              sBytesPush(r, c);\
  3031         -: 2038:              ctx->boolShift  = 5;\
  3032         -: 2039:              ctx->boolOffset = (*r)->count -1
  3033         3: 2040:              storeNew4bPackedBool(e->data);
  3034 branch  0 taken 100% (fallthrough)
  3035 branch  1 taken 0%
  3036 call    2 returned 100%
  3037         -: 2041:            }
  3038         -: 2042:            else {
  3039         -: 2043:              // high nibble, next byte is packed bools
  3040         2: 2044:              storeTypeInHighNbl(e->data);
  3041         -: 2045:              #define storeNew8bPackedBool(o)\
  3042         -: 2046:              u8 c         = 0;\
  3043         -: 2047:              if (((sBoolt *)(o))->value)\
  3044         -: 2048:                c = 1;\
  3045         -: 2049:              sBytesPush(r, c);\
  3046         -: 2050:              ctx->boolShift  = 1;\
  3047         -: 2051:              ctx->boolOffset = (*r)->count -1
  3048         2: 2052:              storeNew8bPackedBool(e->data);
  3049 branch  0 taken 100% (fallthrough)
  3050 branch  1 taken 0%
  3051 call    2 returned 100%
  3052         -: 2053:            }
  3053         -: 2054:          }
  3054         -: 2055:          else {
  3055         -: 2056:            // there was a bool before this one, fill bits in nibbles
  3056        26: 2057:            if (ctx->nibble == lowNbl) {
  3057 branch  0 taken 58% (fallthrough)
  3058 branch  1 taken 42%
  3059        15: 2058:              if (ctx->boolShift == 8) {
  3060 branch  0 taken 7% (fallthrough)
  3061 branch  1 taken 93%
  3062         -: 2059:                // previous packed bool is full
  3063         -: 2060:                // this byte is the new packed bools
  3064         1: 2061:                storeNew4bPackedBool(e->data);
  3065 branch  0 taken 100% (fallthrough)
  3066 branch  1 taken 0%
  3067 call    2 returned 100%
  3068         -: 2062:              }
  3069         -: 2063:              else {
  3070        14: 2064:                storeTypeOnly(e->data);
  3071 call    0 returned 100%
  3072         -: 2065:                #define storeBool(o)\
  3073         -: 2066:                data           = (char *)&((*r)->data) + ctx->boolOffset;\
  3074         -: 2067:                if (((sBoolt *)(o))->value)\
  3075         -: 2068:                  *data |= 1 << ctx->boolShift;\
  3076         -: 2069:                ctx->boolShift++
  3077        14: 2070:                storeBool(e->data);
  3078 branch  0 taken 100% (fallthrough)
  3079 branch  1 taken 0%
  3080         -: 2071:              }
  3081         -: 2072:            }
  3082         -: 2073:            else {
  3083         -: 2074:              // high nibble
  3084        11: 2075:              storeTypeInHighNbl(e->data);
  3085        11: 2076:              if (ctx->boolShift == 8) {
  3086 branch  0 taken 18% (fallthrough)
  3087 branch  1 taken 82%
  3088         -: 2077:                // previous packed bool is full
  3089         -: 2078:                // next byte is the new packed bools
  3090         2: 2079:                storeNew8bPackedBool(e->data);
  3091 branch  0 taken 100% (fallthrough)
  3092 branch  1 taken 0%
  3093 call    2 returned 100%
  3094         -: 2080:              }
  3095         -: 2081:              else {
  3096         9: 2082:                storeBool(e->data);
  3097 branch  0 taken 100% (fallthrough)
  3098 branch  1 taken 0%
  3099         -: 2083:              }
  3100         -: 2084:            }
  3101         -: 2085:          }
  3102        31: 2086:          break;
  3103         -: 2087:        case DICT:
  3104        20: 2088:          if (pack) {
  3105 branch  0 taken 75% (fallthrough)
  3106 branch  1 taken 25%
  3107        15: 2089:            if (type) {
  3108 branch  0 taken 20% (fallthrough)
  3109 branch  1 taken 80%
  3110         -: 2090:              // this is the first packed element
  3111         3: 2091:              if (ctx->nibble == lowNbl) {
  3112 branch  0 taken 67% (fallthrough)
  3113 branch  1 taken 33%
  3114         2: 2092:                uintToNetTypeVarint(r, type, packCount);
  3115 call    0 returned 100%
  3116         -: 2093:              }
  3117         -: 2094:              else {
  3118         -: 2095:                // high nibble
  3119         -: 2096:                // store type in high nibble
  3120         1: 2097:                ctx->nibble  = lowNbl;
  3121         1: 2098:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  3122         1: 2099:                *data       |= type << 4;
  3123         1: 2100:                uintToVarint(r, packCount);
  3124 call    0 returned 100%
  3125         -: 2101:              }
  3126         3: 2102:              type = 0;
  3127         -: 2103:            } // if type
  3128         -: 2104:
  3129        15: 2105:            dictNetSerial(r, (sDictt *)(e->data), ctx, /*packing=*/PACK);
  3130 call    0 returned 100%
  3131         -: 2106:            // stop packing when packCount == 0
  3132        15: 2107:            packCount--;
  3133        15: 2108:            if (!packCount) pack = false;
  3134 branch  0 taken 20% (fallthrough)
  3135 branch  1 taken 80%
  3136         -: 2109:          } // if pack
  3137         -: 2110:          else
  3138         5: 2111:            dictNetSerial(r, (sDictt *)(e->data), ctx, /*packing=*/NOPACKING);
  3139 call    0 returned 100%
  3140        20: 2112:          break;
  3141         -: 2113:        case DOUBLE:
  3142        12: 2114:          if (pack) {
  3143 branch  0 taken 83% (fallthrough)
  3144 branch  1 taken 17%
  3145        10: 2115:            if (type) {
  3146 branch  0 taken 20% (fallthrough)
  3147 branch  1 taken 80%
  3148         -: 2116:              // this is the first packed element
  3149         2: 2117:              if (ctx->nibble == lowNbl) {
  3150 branch  0 taken 50% (fallthrough)
  3151 branch  1 taken 50%
  3152         1: 2118:                uintToNetTypeVarint(r, type, packCount);
  3153 call    0 returned 100%
  3154         -: 2119:              }
  3155         -: 2120:              else {
  3156         -: 2121:                // high nibble
  3157         -: 2122:                // store type in high nibble
  3158         1: 2123:                ctx->nibble  = lowNbl;
  3159         1: 2124:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  3160         1: 2125:                *data       |= type << 4;
  3161         1: 2126:                uintToVarint(r, packCount);
  3162 call    0 returned 100%
  3163         -: 2127:              }
  3164         2: 2128:              type = 0;
  3165         -: 2129:            } // if type
  3166         -: 2130:
  3167        10: 2131:            sBytesPushBuffer(r, &((sDoublet *)(e->data))->value, sizeof(double));
  3168 call    0 returned 100%
  3169         -: 2132:            // stop packing when packCount == 0
  3170        10: 2133:            packCount--;
  3171        10: 2134:            if (!packCount) pack = false;
  3172 branch  0 taken 20% (fallthrough)
  3173 branch  1 taken 80%
  3174         -: 2135:          } // if pack
  3175         -: 2136:          else {
  3176         2: 2137:            if (ctx->nibble == lowNbl) {
  3177 branch  0 taken 50% (fallthrough)
  3178 branch  1 taken 50%
  3179         1: 2138:              storeTypeOnly(e->data);
  3180 call    0 returned 100%
  3181         -: 2139:            }
  3182         -: 2140:            else {
  3183         -: 2141:              // high nibble
  3184         1: 2142:              storeTypeInHighNbl(e->data);
  3185         -: 2143:            }
  3186         2: 2144:            sBytesPushBuffer(r, &((sDoublet *)(e->data))->value, sizeof(double));
  3187 call    0 returned 100%
  3188         -: 2145:          }
  3189        12: 2146:          break;
  3190         -: 2147:        case INT:
  3191        32: 2148:          if (pack) {
  3192 branch  0 taken 25% (fallthrough)
  3193 branch  1 taken 75%
  3194         8: 2149:            if (type) {
  3195 branch  0 taken 25% (fallthrough)
  3196 branch  1 taken 75%
  3197         -: 2150:              // this is the first packed element
  3198         2: 2151:              if (ctx->nibble == lowNbl) {
  3199 branch  0 taken 50% (fallthrough)
  3200 branch  1 taken 50%
  3201         1: 2152:                uintToNetTypeVarint(r, type, packCount);
  3202 call    0 returned 100%
  3203         -: 2153:              }
  3204         -: 2154:              else {
  3205         -: 2155:                // high nibble
  3206         -: 2156:                // store type in high nibble
  3207         1: 2157:                ctx->nibble  = lowNbl;
  3208         1: 2158:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  3209         1: 2159:                *data       |= type << 4;
  3210         1: 2160:                uintToVarint(r, packCount);
  3211 call    0 returned 100%
  3212         -: 2161:              }
  3213         2: 2162:              type = 0;
  3214         -: 2163:            } // if type
  3215         -: 2164:
  3216         8: 2165:            i64 v = ((sIntt *)(e->data))->value;
  3217         8: 2166:            uintToVarint(r, (v << 1) ^ (v >> 63));
  3218 call    0 returned 100%
  3219         -: 2167:            // stop packing when packCount == 0
  3220         8: 2168:            packCount--;
  3221         8: 2169:            if (!packCount) pack = false;
  3222 branch  0 taken 25% (fallthrough)
  3223 branch  1 taken 75%
  3224         -: 2170:          } // if pack
  3225         -: 2171:          else {
  3226         -: 2172:            // encode int to varint
  3227         -: 2173:            // v is int64_t to convert to varint
  3228        24: 2174:            i64 v = ((sIntt *)(e->data))->value;
  3229        24: 2175:            if (ctx->nibble == lowNbl) {
  3230 branch  0 taken 50% (fallthrough)
  3231 branch  1 taken 50%
  3232         -: 2176:              // encode v with arithmetic shifts
  3233        12: 2177:              uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->data->type], (v << 1) ^ (v >> 63));
  3234 call    0 returned 100%
  3235         -: 2178:            }
  3236         -: 2179:            else {
  3237         -: 2180:              // high nibble
  3238        12: 2181:              storeTypeInHighNbl(e->data);
  3239        12: 2182:              uintToVarint(r, (v << 1) ^ (v >> 63));
  3240 call    0 returned 100%
  3241         -: 2183:            }
  3242         -: 2184:          }
  3243        32: 2185:          break;
  3244         -: 2186:        case STRING:
  3245        22: 2187:          if (pack) {
  3246 branch  0 taken 36% (fallthrough)
  3247 branch  1 taken 64%
  3248         8: 2188:            if (type) {
  3249 branch  0 taken 25% (fallthrough)
  3250 branch  1 taken 75%
  3251         -: 2189:              // this is the first packed element
  3252         2: 2190:              if (ctx->nibble == lowNbl) {
  3253 branch  0 taken 50% (fallthrough)
  3254 branch  1 taken 50%
  3255         1: 2191:                uintToNetTypeVarint(r, type, packCount);
  3256 call    0 returned 100%
  3257         -: 2192:              }
  3258         -: 2193:              else {
  3259         -: 2194:                // high nibble
  3260         -: 2195:                // store type in high nibble
  3261         1: 2196:                ctx->nibble  = lowNbl;
  3262         1: 2197:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  3263         1: 2198:                *data       |= type << 4;
  3264         1: 2199:                uintToVarint(r, packCount);
  3265 call    0 returned 100%
  3266         -: 2200:              }
  3267         2: 2201:              type = 0;
  3268         -: 2202:            } // if type
  3269         -: 2203:
  3270         8: 2204:            sBytesPushBuffer(r, &((sStringt *)(e->data))->data, sizeof(sStringt) + strlen(&(((sStringt *)(e->data))->data)) -1);
  3271 call    0 returned 100%
  3272         -: 2205:            // stop packing when packCount == 0
  3273         8: 2206:            packCount--;
  3274         8: 2207:            if (!packCount) pack = false;
  3275 branch  0 taken 25% (fallthrough)
  3276 branch  1 taken 75%
  3277         -: 2208:          } // if pack
  3278         -: 2209:          else {
  3279        14: 2210:            if (ctx->nibble == lowNbl) {
  3280 branch  0 taken 93% (fallthrough)
  3281 branch  1 taken 7%
  3282        13: 2211:              storeTypeOnly(e->data);
  3283 call    0 returned 100%
  3284         -: 2212:            }
  3285         -: 2213:            else {
  3286         -: 2214:              // high nibble
  3287         1: 2215:              storeTypeInHighNbl(e->data);
  3288         -: 2216:            }
  3289        14: 2217:            sBytesPushBuffer(r, &((sStringt *)(e->data))->data, sizeof(sStringt) + strlen(&(((sStringt *)(e->data))->data)) -1);
  3290 call    0 returned 100%
  3291         -: 2218:          }
  3292        22: 2219:          break;
  3293         -: 2220:        case ARRAY:
  3294        15: 2221:          if (pack) {
  3295 branch  0 taken 53% (fallthrough)
  3296 branch  1 taken 47%
  3297         8: 2222:            if (type) {
  3298 branch  0 taken 25% (fallthrough)
  3299 branch  1 taken 75%
  3300         -: 2223:              // this is the first packed element
  3301         2: 2224:              if (ctx->nibble == lowNbl) {
  3302 branch  0 taken 50% (fallthrough)
  3303 branch  1 taken 50%
  3304         1: 2225:                uintToNetTypeVarint(r, type, packCount);
  3305 call    0 returned 100%
  3306         -: 2226:              }
  3307         -: 2227:              else {
  3308         -: 2228:                // high nibble
  3309         -: 2229:                // store type in high nibble
  3310         1: 2230:                ctx->nibble  = lowNbl;
  3311         1: 2231:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  3312         1: 2232:                *data       |= type << 4;
  3313         1: 2233:                uintToVarint(r, packCount);
  3314 call    0 returned 100%
  3315         -: 2234:              }
  3316         2: 2235:              type = 0;
  3317         -: 2236:            } // if type
  3318         -: 2237:
  3319         8: 2238:            arrayNetSerial(r, (sArrayt *)(e->data), ctx, /*packing=*/PACK);
  3320 call    0 returned 100%
  3321         -: 2239:            // stop packing when packCount == 0
  3322         8: 2240:            packCount--;
  3323         8: 2241:            if (!packCount) pack = false;
  3324 branch  0 taken 25% (fallthrough)
  3325 branch  1 taken 75%
  3326         -: 2242:          } // if pack
  3327         -: 2243:          else
  3328         7: 2244:            arrayNetSerial(r, (sArrayt *)(e->data), ctx, /*packing=*/NOPACKING);
  3329 call    0 returned 100%
  3330        15: 2245:          break;
  3331         -: 2246:        case BYTES:
  3332         2: 2247:          if (pack) {
  3333 branch  0 taken 0% (fallthrough)
  3334 branch  1 taken 100%
  3335     #####: 2248:            if (type) {
  3336 branch  0 never executed
  3337 branch  1 never executed
  3338         -: 2249:              // this is the first packed element
  3339     #####: 2250:              if (ctx->nibble == lowNbl) {
  3340 branch  0 never executed
  3341 branch  1 never executed
  3342     #####: 2251:                uintToNetTypeVarint(r, type, packCount);
  3343 call    0 never executed
  3344         -: 2252:              }
  3345         -: 2253:              else {
  3346         -: 2254:                // high nibble
  3347         -: 2255:                // store type in high nibble
  3348     #####: 2256:                ctx->nibble  = lowNbl;
  3349     #####: 2257:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  3350     #####: 2258:                *data       |= type << 4;
  3351     #####: 2259:                uintToVarint(r, packCount);
  3352 call    0 never executed
  3353         -: 2260:              }
  3354     #####: 2261:              type = 0;
  3355         -: 2262:            } // if type
  3356         -: 2263:
  3357     #####: 2264:            B = (sBytest *)(e->data);
  3358     #####: 2265:            uintToVarint(r, B->count);
  3359 call    0 never executed
  3360     #####: 2266:            sBytesPushBuffer(r, &(B->data), B->count);
  3361 call    0 never executed
  3362         -: 2267:            // stop packing when packCount == 0
  3363     #####: 2268:            packCount--;
  3364     #####: 2269:            if (!packCount) pack = false;
  3365 branch  0 never executed
  3366 branch  1 never executed
  3367         -: 2270:          } // if pack
  3368         -: 2271:          else {
  3369         2: 2272:            B = (sBytest *)(e->data);
  3370         2: 2273:            if (ctx->nibble == lowNbl) {
  3371 branch  0 taken 50% (fallthrough)
  3372 branch  1 taken 50%
  3373         1: 2274:              uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->data->type], B->count);
  3374 call    0 returned 100%
  3375         -: 2275:            }
  3376         -: 2276:            else {
  3377         -: 2277:              // high nibble
  3378         1: 2278:              storeTypeInHighNbl(e->data);
  3379         1: 2279:              uintToVarint(r, B->count);
  3380 call    0 returned 100%
  3381         -: 2280:            }
  3382         2: 2281:            sBytesPushBuffer(r, &(B->data), B->count);
  3383 call    0 returned 100%
  3384         -: 2282:          }
  3385         2: 2283:          break;
  3386         -: 2284:      }
  3387         -: 2285:    }
  3388         -: 2286:  }
  3389        56: 2287:  ret;
  3390         -: 2288:}
  3391         -: 2289:
  3392         -: 2290:/**
  3393         -: 2291: * serialize array
  3394         -: 2292: *
  3395         -: 2293: * the serialized array is pushed to r.
  3396         -: 2294: * All elements are serialized recursively
  3397         -: 2295: *
  3398         -: 2296: * the data in containers is not serialized
  3399         -: 2297: *
  3400         -: 2298: * \param
  3401         -: 2299: *   r small bytes object
  3402         -: 2300: *   array to serialize
  3403         -: 2301: */
  3404 function arrayNetSerial called 78 returned 100% blocks executed 91%
  3405        78: 2302:internal void arrayNetSerial(sBytest **r, sArrayt *array, contextt *ctx, packingT packing) {
  3406        78: 2303:  sBytest *B     = NULL;
  3407        78: 2304:  char    *data  = NULL;
  3408         -: 2305:
  3409         -: 2306:  // check if all elements have same type
  3410         -: 2307:  // then set array type normal or uniform
  3411         -: 2308:  // array and dict have to be checked recursively to know if they are normal or uniform
  3412        78: 2309:  bool allElementsHaveSameType = true;
  3413        78: 2310:  bool foundFirstType          = false;
  3414        78: 2311:  char type                    = 0;
  3415         -: 2312:
  3416         -: 2313:  // get first element type
  3417         -: 2314:  // compare to other element type
  3418         -: 2315:  // null element are interpreted as undefined
  3419       230: 2316:  {forEachSArray(array, e) {
  3420 branch  0 taken 82%
  3421 branch  1 taken 18% (fallthrough)
  3422       189: 2317:    if (!e) {
  3423 branch  0 taken 0% (fallthrough)
  3424 branch  1 taken 100%
  3425     #####: 2318:      if (foundFirstType) {
  3426 branch  0 never executed
  3427 branch  1 never executed
  3428     #####: 2319:        if (type != S_UNDEFINED) {
  3429 branch  0 never executed
  3430 branch  1 never executed
  3431     #####: 2320:          allElementsHaveSameType = false;
  3432     #####: 2321:          break;
  3433         -: 2322:        }
  3434         -: 2323:      }
  3435         -: 2324:      else {
  3436     #####: 2325:        type = S_UNDEFINED;
  3437     #####: 2326:        foundFirstType = true;
  3438         -: 2327:      }
  3439         -: 2328:    }
  3440         -: 2329:    else {
  3441       189: 2330:      if (foundFirstType) {
  3442 branch  0 taken 61% (fallthrough)
  3443 branch  1 taken 39%
  3444         -: 2331:        u8 nextType;
  3445       115: 2332:        switch(e->type) {
  3446 branch  0 taken 6%
  3447 branch  1 taken 10%
  3448 branch  2 taken 84%
  3449         -: 2333:          case DICT:
  3450         7: 2334:            nextType = isDictUniform((sDictt*)e);
  3451 call    0 returned 100%
  3452         7: 2335:            break;
  3453         -: 2336:          case ARRAY:
  3454        11: 2337:            nextType = isArrayUniform((sArrayt*)e);
  3455 call    0 returned 100%
  3456        11: 2338:            break;
  3457         -: 2339:          default:
  3458        97: 2340:            nextType = NET_SERIAL_TYPES[(u8)e->type];
  3459         -: 2341:        }
  3460       115: 2342:        if (nextType != type) {
  3461 branch  0 taken 32% (fallthrough)
  3462 branch  1 taken 68%
  3463        37: 2343:          allElementsHaveSameType = false;
  3464        37: 2344:          break;
  3465         -: 2345:        }
  3466         -: 2346:      }
  3467         -: 2347:      else {
  3468        74: 2348:        switch(e->type) {
  3469 branch  0 taken 7%
  3470 branch  1 taken 8%
  3471 branch  2 taken 85%
  3472         -: 2349:          case DICT:
  3473         5: 2350:            type = isDictUniform((sDictt*)e);
  3474 call    0 returned 100%
  3475         5: 2351:            break;
  3476         -: 2352:          case ARRAY:
  3477         6: 2353:            type = isArrayUniform((sArrayt*)e);
  3478 call    0 returned 100%
  3479         6: 2354:            break;
  3480         -: 2355:          default:
  3481        63: 2356:            type = NET_SERIAL_TYPES[(u8)e->type];
  3482         -: 2357:        }
  3483        74: 2358:        foundFirstType = true;
  3484         -: 2359:      }
  3485         -: 2360:    }
  3486         -: 2361:  }}
  3487         -: 2362:
  3488        78: 2363:  if (allElementsHaveSameType) {
  3489 branch  0 taken 53% (fallthrough)
  3490 branch  1 taken 47%
  3491         -: 2364:    // uniform array
  3492         -: 2365:    // encode type and element count
  3493         -: 2366:
  3494         -: 2367:    // in pack array
  3495        41: 2368:    if (packing == PACK) {
  3496 branch  0 taken 39% (fallthrough)
  3497 branch  1 taken 61%
  3498         -: 2369:      // uniform array can't be packed
  3499         -: 2370:      // because there is only one type of packed arrays
  3500        16: 2371:      goto normalArray;
  3501         -: 2372:    }
  3502        25: 2373:    elif (packing == UNIFORM) {
  3503 branch  0 taken 8% (fallthrough)
  3504 branch  1 taken 92%
  3505         -: 2374:      // when the packing is uniform, there is no need to encode UNIFORM_ARRAY since all elements have this type
  3506         2: 2375:      uintToNetTypeVarint(r, type, array->count);
  3507 call    0 returned 100%
  3508         -: 2376:    }
  3509         -: 2377:    else {
  3510        23: 2378:      if (ctx->nibble == lowNbl) {
  3511 branch  0 taken 78% (fallthrough)
  3512 branch  1 taken 22%
  3513        18: 2379:        sBytesPush(r, (type << 4) + UNIFORM_ARRAY);
  3514 call    0 returned 100%
  3515        18: 2380:        uintToVarint(r, array->count);
  3516 call    0 returned 100%
  3517         -: 2381:      }
  3518         -: 2382:      else {
  3519         -: 2383:        // high nibble
  3520         5: 2384:        ctx->nibble  = lowNbl;
  3521         5: 2385:        data         = (char *)&((*r)->data) + ctx->nblOffset;
  3522         5: 2386:        *data       |= UNIFORM_ARRAY << 4;
  3523         5: 2387:        uintToNetTypeVarint(r, type, array->count);
  3524 call    0 returned 100%
  3525         -: 2388:      }
  3526         -: 2389:    }
  3527         -: 2390:
  3528         -: 2391:    // encode all element values
  3529        25: 2392:    switch(type) {
  3530 branch  0 taken 8%
  3531 branch  1 taken 8%
  3532 branch  2 taken 4%
  3533 branch  3 taken 44%
  3534 branch  4 taken 4%
  3535 branch  5 taken 16%
  3536 branch  6 taken 4%
  3537 branch  7 taken 12%
  3538         -: 2393:      case S_BOOL:
  3539        16: 2394:        {forEachSArray(array, e) {
  3540 branch  0 taken 88%
  3541 branch  1 taken 13% (fallthrough)
  3542        14: 2395:          if (!ctx->boolOffset) {
  3543 branch  0 taken 14% (fallthrough)
  3544 branch  1 taken 86%
  3545         -: 2396:            // new packed bools
  3546         2: 2397:            storeNew8bPackedBool(e);
  3547 branch  0 taken 100% (fallthrough)
  3548 branch  1 taken 0%
  3549 call    2 returned 100%
  3550         -: 2398:          }
  3551         -: 2399:          else {
  3552         -: 2400:            // there was a bool before this one, fill bits in nibbles
  3553        12: 2401:            if (ctx->boolShift == 8) {
  3554 branch  0 taken 8% (fallthrough)
  3555 branch  1 taken 92%
  3556         -: 2402:              // previous packed bool is full
  3557         -: 2403:              // next byte is the new packed bools
  3558         1: 2404:              storeNew8bPackedBool(e);
  3559 branch  0 taken 0% (fallthrough)
  3560 branch  1 taken 100%
  3561 call    2 returned 100%
  3562         -: 2405:            }
  3563         -: 2406:            else {
  3564        11: 2407:              storeBool(e);
  3565 branch  0 taken 100% (fallthrough)
  3566 branch  1 taken 0%
  3567         -: 2408:            }
  3568         -: 2409:          }
  3569         -: 2410:        }}
  3570         2: 2411:        break;
  3571         -: 2412:      case S_DICT:
  3572         -: 2413:      case UNIFORM_DICT:
  3573         6: 2414:        {forEachSArray(array, e) {
  3574 branch  0 taken 67%
  3575 branch  1 taken 33% (fallthrough)
  3576         4: 2415:          dictNetSerial(r, (sDictt *)e, ctx, /*packing=*/UNIFORM);
  3577 call    0 returned 100%
  3578         -: 2416:        }}
  3579         2: 2417:        break;
  3580         -: 2418:      case S_DOUBLE:
  3581         4: 2419:        {forEachSArray(array, e) {
  3582 branch  0 taken 75%
  3583 branch  1 taken 25% (fallthrough)
  3584         3: 2420:          sBytesPushBuffer(r, &((sDoublet *)e)->value, sizeof(double));
  3585 call    0 returned 100%
  3586         -: 2421:        }}
  3587         1: 2422:        break;
  3588         -: 2423:      case S_INT:
  3589        49: 2424:        {forEachSArray(array, e) {
  3590 branch  0 taken 78%
  3591 branch  1 taken 22% (fallthrough)
  3592        38: 2425:          i64 v = ((sIntt *)e)->value;
  3593        38: 2426:          uintToVarint(r, (v << 1) ^ (v >> 63));
  3594 call    0 returned 100%
  3595         -: 2427:        }}
  3596        11: 2428:        break;
  3597         -: 2429:      case S_STRING:
  3598         4: 2430:        {forEachSArray(array, e) {
  3599 branch  0 taken 75%
  3600 branch  1 taken 25% (fallthrough)
  3601         3: 2431:          sBytesPushBuffer(r, &((sStringt *)e)->data, sizeof(sStringt) + strlen(&(((sStringt *)e)->data)) -1);
  3602 call    0 returned 100%
  3603         -: 2432:        }}
  3604         1: 2433:        break;
  3605         -: 2434:      case S_ARRAY:
  3606         -: 2435:      case UNIFORM_ARRAY:
  3607        10: 2436:        {forEachSArray(array, e) {
  3608 branch  0 taken 60%
  3609 branch  1 taken 40% (fallthrough)
  3610         6: 2437:          arrayNetSerial(r, (sArrayt *)e, ctx, /*packing=*/UNIFORM);
  3611 call    0 returned 100%
  3612         -: 2438:        }}
  3613         4: 2439:        break;
  3614         -: 2440:      case S_BYTES:
  3615         3: 2441:        {forEachSArray(array, e) {
  3616 branch  0 taken 67%
  3617 branch  1 taken 33% (fallthrough)
  3618         2: 2442:          B = (sBytest *)e;
  3619         2: 2443:          uintToVarint(r, B->count);
  3620 call    0 returned 100%
  3621         2: 2444:          sBytesPushBuffer(r, &(B->data), B->count);
  3622 call    0 returned 100%
  3623         -: 2445:        }}
  3624         1: 2446:        break;
  3625         -: 2447:    }
  3626        25: 2448:    ret;
  3627         -: 2449:  }
  3628         -: 2450:
  3629         -: 2451:  normalArray:
  3630         -: 2452:  // encode type and element count
  3631        53: 2453:  if (packing == PACK or packing == UNIFORM) {
  3632 branch  0 taken 70% (fallthrough)
  3633 branch  1 taken 30%
  3634 branch  2 taken 16% (fallthrough)
  3635 branch  3 taken 84%
  3636         -: 2454:    // when the packing is packed or uniform, there is no need to encode ARRAY type since all elements have this type
  3637        22: 2455:    uintToVarint(r, array->count);
  3638 call    0 returned 100%
  3639         -: 2456:  }
  3640         -: 2457:  else {
  3641        31: 2458:    if (ctx->nibble == lowNbl) {
  3642 branch  0 taken 90% (fallthrough)
  3643 branch  1 taken 10%
  3644        28: 2459:      uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)array->type], array->count);
  3645 call    0 returned 100%
  3646         -: 2460:    }
  3647         -: 2461:    else {
  3648         -: 2462:      // high nibble
  3649         3: 2463:      storeTypeInHighNbl(array);
  3650         3: 2464:      uintToVarint(r, array->count);
  3651 call    0 returned 100%
  3652         -: 2465:    }
  3653         -: 2466:  }
  3654         -: 2467:
  3655        53: 2468:  bool   pack = false;
  3656         -: 2469:  size_t packCount;
  3657       218: 2470:  enumerateSArray(array, e, eIdx) {
  3658 branch  0 taken 76%
  3659 branch  1 taken 24% (fallthrough)
  3660       165: 2471:    if (!e) {
  3661 branch  0 taken 0% (fallthrough)
  3662 branch  1 taken 100%
  3663         -: 2472:      // empty slots are represented as undefined elements
  3664     #####: 2473:      if (ctx->nibble == lowNbl) {
  3665 branch  0 never executed
  3666 branch  1 never executed
  3667     #####: 2474:        sBytesPush(r, NET_SERIAL_TYPES[UNDEFINED]);
  3668 call    0 never executed
  3669     #####: 2475:        ctx->nibble    = highNbl;
  3670     #####: 2476:        ctx->nblOffset = (*r)->count -1;
  3671         -: 2477:      }
  3672         -: 2478:      else {
  3673         -: 2479:        // high nibble
  3674     #####: 2480:        ctx->nibble  = lowNbl;
  3675     #####: 2481:        data         = (char *)&((*r)->data) + ctx->nblOffset;
  3676     #####: 2482:        *data       |= NET_SERIAL_TYPES[UNDEFINED] << 4;
  3677         -: 2483:      }
  3678         -: 2484:    }
  3679         -: 2485:    else {
  3680       165: 2486:      if (!pack) {
  3681 branch  0 taken 82% (fallthrough)
  3682 branch  1 taken 18%
  3683         -: 2487:        // scan array for packing
  3684       135: 2488:        if ((array->count - eIdx) > 3) {
  3685 branch  0 taken 30% (fallthrough)
  3686 branch  1 taken 70%
  3687         -: 2489:          // at least 4 elements, less than that is not worth it
  3688        41: 2490:          if (   e->type == DICT
  3689 branch  0 taken 90% (fallthrough)
  3690 branch  1 taken 10%
  3691        37: 2491:              or e->type == DOUBLE
  3692 branch  0 taken 95% (fallthrough)
  3693 branch  1 taken 5%
  3694        35: 2492:              or e->type == INT
  3695 branch  0 taken 89% (fallthrough)
  3696 branch  1 taken 11%
  3697        31: 2493:              or e->type == STRING
  3698 branch  0 taken 94% (fallthrough)
  3699 branch  1 taken 6%
  3700        29: 2494:              or e->type == ARRAY
  3701 branch  0 taken 93% (fallthrough)
  3702 branch  1 taken 7%
  3703        27: 2495:              or e->type == BYTES) {
  3704 branch  0 taken 0% (fallthrough)
  3705 branch  1 taken 100%
  3706        14: 2496:            type      = e->type;
  3707        14: 2497:            packCount = 1;
  3708        14: 2498:            smallt *element = ((smallt **) &((array)->data))[eIdx+1];
  3709        47: 2499:            for (size_t i = eIdx+1; i < (array)->count ; i++, element = ((smallt **) &((array)->data))[i]) {
  3710 branch  0 taken 100%
  3711 branch  1 taken 0% (fallthrough)
  3712        47: 2500:              if (!element) {
  3713 branch  0 taken 0% (fallthrough)
  3714 branch  1 taken 100%
  3715         -: 2501:                // null element are undefined
  3716     #####: 2502:                break;
  3717         -: 2503:              }
  3718         -: 2504:              else {
  3719        47: 2505:                if (element->type != type) {
  3720 branch  0 taken 30% (fallthrough)
  3721 branch  1 taken 70%
  3722        14: 2506:                  break;
  3723         -: 2507:                }
  3724        33: 2508:                packCount++;
  3725         -: 2509:              } // if element
  3726         -: 2510:            } // for
  3727        14: 2511:            if (packCount > 3) {
  3728 branch  0 taken 71% (fallthrough)
  3729 branch  1 taken 29%
  3730        10: 2512:              type = PACKED_NET_SERIAL_TYPES[(u8)type];
  3731        10: 2513:              pack = true;
  3732         -: 2514:            }
  3733         -: 2515:          } // test current element type
  3734         -: 2516:        } // is array big enough
  3735         -: 2517:      } // not already packing
  3736         -: 2518:
  3737         -: 2519:      // encode element value
  3738       165: 2520:      switch(e->type) {
  3739 branch  0 taken 18%
  3740 branch  1 taken 22%
  3741 branch  2 taken 9%
  3742 branch  3 taken 6%
  3743 branch  4 taken 22%
  3744 branch  5 taken 13%
  3745 branch  6 taken 10%
  3746 branch  7 taken 1%
  3747 branch  8 taken 0%
  3748         -: 2521:        case UNDEFINED:
  3749         -: 2522:        case CONTAINER:
  3750        29: 2523:          if (ctx->nibble == lowNbl) {
  3751 branch  0 taken 93% (fallthrough)
  3752 branch  1 taken 7%
  3753        27: 2524:            storeTypeOnly(e);
  3754 call    0 returned 100%
  3755         -: 2525:          }
  3756         -: 2526:          else {
  3757         -: 2527:            // high nibble
  3758         2: 2528:            storeTypeInHighNbl(e);
  3759         -: 2529:          }
  3760        29: 2530:          break;
  3761         -: 2531:        case BOOL:
  3762        36: 2532:          if (!ctx->boolOffset) {
  3763 branch  0 taken 22% (fallthrough)
  3764 branch  1 taken 78%
  3765         -: 2533:            // new packed bools
  3766         8: 2534:            if (ctx->nibble == lowNbl) {
  3767 branch  0 taken 63% (fallthrough)
  3768 branch  1 taken 38%
  3769         5: 2535:              storeNew4bPackedBool(e);
  3770 branch  0 taken 80% (fallthrough)
  3771 branch  1 taken 20%
  3772 call    2 returned 100%
  3773         -: 2536:            }
  3774         -: 2537:            else {
  3775         -: 2538:              // high nibble, next byte is packed bools
  3776         3: 2539:              storeTypeInHighNbl(e);
  3777         3: 2540:              storeNew8bPackedBool(e);
  3778 branch  0 taken 100% (fallthrough)
  3779 branch  1 taken 0%
  3780 call    2 returned 100%
  3781         -: 2541:            }
  3782         -: 2542:          }
  3783         -: 2543:          else {
  3784         -: 2544:            // there was a bool before this one, fill bits in nibbles
  3785        28: 2545:            if (ctx->nibble == lowNbl) {
  3786 branch  0 taken 61% (fallthrough)
  3787 branch  1 taken 39%
  3788        17: 2546:              if (ctx->boolShift == 8) {
  3789 branch  0 taken 12% (fallthrough)
  3790 branch  1 taken 88%
  3791         -: 2547:                // previous packed bool is full
  3792         -: 2548:                // this byte is the new packed bools
  3793         2: 2549:                storeNew4bPackedBool(e);
  3794 branch  0 taken 50% (fallthrough)
  3795 branch  1 taken 50%
  3796 call    2 returned 100%
  3797         -: 2550:              }
  3798         -: 2551:              else {
  3799        15: 2552:                storeTypeOnly(e);
  3800 call    0 returned 100%
  3801        15: 2553:                storeBool(e);
  3802 branch  0 taken 53% (fallthrough)
  3803 branch  1 taken 47%
  3804         -: 2554:              }
  3805         -: 2555:            }
  3806         -: 2556:            else {
  3807         -: 2557:              // high nibble
  3808        11: 2558:              storeTypeInHighNbl(e);
  3809        11: 2559:              if (ctx->boolShift == 8) {
  3810 branch  0 taken 18% (fallthrough)
  3811 branch  1 taken 82%
  3812         -: 2560:                // previous packed bool is full
  3813         -: 2561:                // next byte is the new packed bools
  3814         2: 2562:                storeNew8bPackedBool(e);
  3815 branch  0 taken 100% (fallthrough)
  3816 branch  1 taken 0%
  3817 call    2 returned 100%
  3818         -: 2563:              }
  3819         -: 2564:              else {
  3820         9: 2565:                storeBool(e);
  3821 branch  0 taken 78% (fallthrough)
  3822 branch  1 taken 22%
  3823         -: 2566:              }
  3824         -: 2567:            }
  3825         -: 2568:          }
  3826        36: 2569:          break;
  3827         -: 2570:        case DICT:
  3828        15: 2571:          if (pack) {
  3829 branch  0 taken 53% (fallthrough)
  3830 branch  1 taken 47%
  3831         8: 2572:            if (type) {
  3832 branch  0 taken 25% (fallthrough)
  3833 branch  1 taken 75%
  3834         -: 2573:              // this is the first packed element
  3835         2: 2574:              if (ctx->nibble == lowNbl) {
  3836 branch  0 taken 50% (fallthrough)
  3837 branch  1 taken 50%
  3838         1: 2575:                uintToNetTypeVarint(r, type, packCount);
  3839 call    0 returned 100%
  3840         -: 2576:              }
  3841         -: 2577:              else {
  3842         -: 2578:                // high nibble
  3843         -: 2579:                // store type in high nibble
  3844         1: 2580:                ctx->nibble  = lowNbl;
  3845         1: 2581:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  3846         1: 2582:                *data       |= type << 4;
  3847         1: 2583:                uintToVarint(r, packCount);
  3848 call    0 returned 100%
  3849         -: 2584:              }
  3850         2: 2585:              type = 0;
  3851         -: 2586:            } // if type
  3852         -: 2587:
  3853         8: 2588:            dictNetSerial(r, (sDictt *)e, ctx, /*packing=*/PACK);
  3854 call    0 returned 100%
  3855         -: 2589:            // stop packing when packCount == 0
  3856         8: 2590:            packCount--;
  3857         8: 2591:            if (!packCount) pack = false;
  3858 branch  0 taken 25% (fallthrough)
  3859 branch  1 taken 75%
  3860         -: 2592:          } // if pack
  3861         -: 2593:          else
  3862         7: 2594:            dictNetSerial(r, (sDictt *)e, ctx, /*packing=*/NOPACKING);
  3863 call    0 returned 100%
  3864        15: 2595:          break;
  3865         -: 2596:        case DOUBLE:
  3866        10: 2597:          if (pack) {
  3867 branch  0 taken 80% (fallthrough)
  3868 branch  1 taken 20%
  3869         8: 2598:            if (type) {
  3870 branch  0 taken 25% (fallthrough)
  3871 branch  1 taken 75%
  3872         -: 2599:              // this is the first packed element
  3873         2: 2600:              if (ctx->nibble == lowNbl) {
  3874 branch  0 taken 50% (fallthrough)
  3875 branch  1 taken 50%
  3876         1: 2601:                uintToNetTypeVarint(r, type, packCount);
  3877 call    0 returned 100%
  3878         -: 2602:              }
  3879         -: 2603:              else {
  3880         -: 2604:                // high nibble
  3881         -: 2605:                // store type in high nibble
  3882         1: 2606:                ctx->nibble  = lowNbl;
  3883         1: 2607:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  3884         1: 2608:                *data       |= type << 4;
  3885         1: 2609:                uintToVarint(r, packCount);
  3886 call    0 returned 100%
  3887         -: 2610:              }
  3888         2: 2611:              type = 0;
  3889         -: 2612:            } // if type
  3890         -: 2613:
  3891         8: 2614:            sBytesPushBuffer(r, &((sDoublet *)e)->value, sizeof(double));
  3892 call    0 returned 100%
  3893         -: 2615:            // stop packing when packCount == 0
  3894         8: 2616:            packCount--;
  3895         8: 2617:            if (!packCount) pack = false;
  3896 branch  0 taken 25% (fallthrough)
  3897 branch  1 taken 75%
  3898         -: 2618:          } // if pack
  3899         -: 2619:          else {
  3900         2: 2620:            if (ctx->nibble == lowNbl) {
  3901 branch  0 taken 50% (fallthrough)
  3902 branch  1 taken 50%
  3903         1: 2621:              storeTypeOnly(e);
  3904 call    0 returned 100%
  3905         -: 2622:            }
  3906         -: 2623:            else {
  3907         -: 2624:              // high nibble
  3908         1: 2625:              storeTypeInHighNbl(e);
  3909         -: 2626:            }
  3910         2: 2627:            sBytesPushBuffer(r, &((sDoublet *)e)->value, sizeof(double));
  3911 call    0 returned 100%
  3912         -: 2628:          }
  3913        10: 2629:          break;
  3914         -: 2630:        case INT:
  3915        36: 2631:          if (pack) {
  3916 branch  0 taken 22% (fallthrough)
  3917 branch  1 taken 78%
  3918         8: 2632:            if (type) {
  3919 branch  0 taken 25% (fallthrough)
  3920 branch  1 taken 75%
  3921         -: 2633:              // this is the first packed element
  3922         2: 2634:              if (ctx->nibble == lowNbl) {
  3923 branch  0 taken 50% (fallthrough)
  3924 branch  1 taken 50%
  3925         1: 2635:                uintToNetTypeVarint(r, type, packCount);
  3926 call    0 returned 100%
  3927         -: 2636:              }
  3928         -: 2637:              else {
  3929         -: 2638:                // high nibble
  3930         -: 2639:                // store type in high nibble
  3931         1: 2640:                ctx->nibble  = lowNbl;
  3932         1: 2641:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  3933         1: 2642:                *data       |= type << 4;
  3934         1: 2643:                uintToVarint(r, packCount);
  3935 call    0 returned 100%
  3936         -: 2644:              }
  3937         2: 2645:              type = 0;
  3938         -: 2646:            } // if type
  3939         -: 2647:
  3940         8: 2648:            i64 v = ((sIntt *)&(e->type))->value;
  3941         8: 2649:            uintToVarint(r, (v << 1) ^ (v >> 63));
  3942 call    0 returned 100%
  3943         -: 2650:            // stop packing when packCount == 0
  3944         8: 2651:            packCount--;
  3945         8: 2652:            if (!packCount) pack = false;
  3946 branch  0 taken 25% (fallthrough)
  3947 branch  1 taken 75%
  3948         -: 2653:          } // if pack
  3949         -: 2654:          else {
  3950         -: 2655:            // encode int to varint
  3951         -: 2656:            // v is int64_t to convert to varint
  3952        28: 2657:            i64 v = ((sIntt *)&(e->type))->value;
  3953        28: 2658:            if (ctx->nibble == lowNbl) {
  3954 branch  0 taken 86% (fallthrough)
  3955 branch  1 taken 14%
  3956         -: 2659:              // encode v with arithmetic shifts
  3957        24: 2660:              uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->type], (v << 1) ^ (v >> 63));
  3958 call    0 returned 100%
  3959         -: 2661:            }
  3960         -: 2662:            else {
  3961         -: 2663:              // high nibble
  3962         4: 2664:              storeTypeInHighNbl(e);
  3963         4: 2665:              uintToVarint(r, (v << 1) ^ (v >> 63));
  3964 call    0 returned 100%
  3965         -: 2666:            }
  3966         -: 2667:          }
  3967        36: 2668:          break;
  3968         -: 2669:        case STRING:
  3969        21: 2670:          if (pack) {
  3970 branch  0 taken 38% (fallthrough)
  3971 branch  1 taken 62%
  3972         8: 2671:            if (type) {
  3973 branch  0 taken 25% (fallthrough)
  3974 branch  1 taken 75%
  3975         -: 2672:              // this is the first packed element
  3976         2: 2673:              if (ctx->nibble == lowNbl) {
  3977 branch  0 taken 50% (fallthrough)
  3978 branch  1 taken 50%
  3979         1: 2674:                uintToNetTypeVarint(r, type, packCount);
  3980 call    0 returned 100%
  3981         -: 2675:              }
  3982         -: 2676:              else {
  3983         -: 2677:                // high nibble
  3984         -: 2678:                // store type in high nibble
  3985         1: 2679:                ctx->nibble  = lowNbl;
  3986         1: 2680:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  3987         1: 2681:                *data       |= type << 4;
  3988         1: 2682:                uintToVarint(r, packCount);
  3989 call    0 returned 100%
  3990         -: 2683:              }
  3991         2: 2684:              type = 0;
  3992         -: 2685:            } // if type
  3993         -: 2686:
  3994         8: 2687:            sBytesPushBuffer(r, &((sStringt *)e)->data, sizeof(sStringt) + strlen(&(((sStringt *)e)->data)) -1);
  3995 call    0 returned 100%
  3996         -: 2688:            // stop packing when packCount == 0
  3997         8: 2689:            packCount--;
  3998         8: 2690:            if (!packCount) pack = false;
  3999 branch  0 taken 25% (fallthrough)
  4000 branch  1 taken 75%
  4001         -: 2691:          } // if pack
  4002         -: 2692:          else {
  4003        13: 2693:            if (ctx->nibble == lowNbl) {
  4004 branch  0 taken 69% (fallthrough)
  4005 branch  1 taken 31%
  4006         9: 2694:              storeTypeOnly(e);
  4007 call    0 returned 100%
  4008         -: 2695:            }
  4009         -: 2696:            else {
  4010         -: 2697:              // high nibble
  4011         4: 2698:              storeTypeInHighNbl(e);
  4012         -: 2699:            }
  4013        13: 2700:            sBytesPushBuffer(r, &((sStringt *)e)->data, sizeof(sStringt) + strlen(&(((sStringt *)e)->data)) -1);
  4014 call    0 returned 100%
  4015         -: 2701:          }
  4016        21: 2702:          break;
  4017         -: 2703:        case ARRAY:
  4018        16: 2704:          if (pack) {
  4019 branch  0 taken 50% (fallthrough)
  4020 branch  1 taken 50%
  4021         8: 2705:            if (type) {
  4022 branch  0 taken 25% (fallthrough)
  4023 branch  1 taken 75%
  4024         -: 2706:              // this is the first packed element
  4025         2: 2707:              if (ctx->nibble == lowNbl) {
  4026 branch  0 taken 50% (fallthrough)
  4027 branch  1 taken 50%
  4028         1: 2708:                uintToNetTypeVarint(r, type, packCount);
  4029 call    0 returned 100%
  4030         -: 2709:              }
  4031         -: 2710:              else {
  4032         -: 2711:                // high nibble
  4033         -: 2712:                // store type in high nibble
  4034         1: 2713:                ctx->nibble  = lowNbl;
  4035         1: 2714:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  4036         1: 2715:                *data       |= type << 4;
  4037         1: 2716:                uintToVarint(r, packCount);
  4038 call    0 returned 100%
  4039         -: 2717:              }
  4040         2: 2718:              type = 0;
  4041         -: 2719:            } // if type
  4042         -: 2720:
  4043         8: 2721:            arrayNetSerial(r, (sArrayt *)e, ctx, /*packing=*/PACK);
  4044 call    0 returned 100%
  4045         -: 2722:            // stop packing when packCount == 0
  4046         8: 2723:            packCount--;
  4047         8: 2724:            if (!packCount) pack = false;
  4048 branch  0 taken 25% (fallthrough)
  4049 branch  1 taken 75%
  4050         -: 2725:          } // if pack
  4051         -: 2726:          else
  4052         8: 2727:            arrayNetSerial(r, (sArrayt *)e, ctx, /*packing=*/NOPACKING);
  4053 call    0 returned 100%
  4054        16: 2728:          break;
  4055         -: 2729:        case BYTES:
  4056         2: 2730:          if (pack) {
  4057 branch  0 taken 0% (fallthrough)
  4058 branch  1 taken 100%
  4059     #####: 2731:            if (type) {
  4060 branch  0 never executed
  4061 branch  1 never executed
  4062         -: 2732:              // this is the first packed element
  4063     #####: 2733:              if (ctx->nibble == lowNbl) {
  4064 branch  0 never executed
  4065 branch  1 never executed
  4066     #####: 2734:                uintToNetTypeVarint(r, type, packCount);
  4067 call    0 never executed
  4068         -: 2735:              }
  4069         -: 2736:              else {
  4070         -: 2737:                // high nibble
  4071         -: 2738:                // store type in high nibble
  4072     #####: 2739:                ctx->nibble  = lowNbl;
  4073     #####: 2740:                data         = (char *)&((*r)->data) + ctx->nblOffset;
  4074     #####: 2741:                *data       |= type << 4;
  4075     #####: 2742:                uintToVarint(r, packCount);
  4076 call    0 never executed
  4077         -: 2743:              }
  4078     #####: 2744:              type = 0;
  4079         -: 2745:            } // if type
  4080         -: 2746:
  4081     #####: 2747:            B = (sBytest *)e;
  4082     #####: 2748:            uintToVarint(r, B->count);
  4083 call    0 never executed
  4084     #####: 2749:            sBytesPushBuffer(r, &(B->data), B->count);
  4085 call    0 never executed
  4086         -: 2750:            // stop packing when packCount == 0
  4087     #####: 2751:            packCount--;
  4088     #####: 2752:            if (!packCount) pack = false;
  4089 branch  0 never executed
  4090 branch  1 never executed
  4091         -: 2753:          } // if pack
  4092         -: 2754:          else {
  4093         2: 2755:            B = (sBytest *)e;
  4094         2: 2756:            if (ctx->nibble == lowNbl) {
  4095 branch  0 taken 50% (fallthrough)
  4096 branch  1 taken 50%
  4097         1: 2757:              uintToNetTypeVarint(r, NET_SERIAL_TYPES[(u8)e->type], B->count);
  4098 call    0 returned 100%
  4099         -: 2758:            }
  4100         -: 2759:            else {
  4101         -: 2760:              // high nibble
  4102         1: 2761:              storeTypeInHighNbl(e);
  4103         1: 2762:              uintToVarint(r, B->count);
  4104 call    0 returned 100%
  4105         -: 2763:            }
  4106         2: 2764:            sBytesPushBuffer(r, &(B->data), B->count);
  4107 call    0 returned 100%
  4108         -: 2765:          }
  4109         2: 2766:          break;
  4110         -: 2767:      }
  4111         -: 2768:    }
  4112         -: 2769:  }
  4113        53: 2770:  ret;
  4114         -: 2771:}
  4115         -: 2772:
  4116 function serialNetSerial called 86 returned 100% blocks executed 80%
  4117        86: 2773:internal smallBytest* serialNetSerial(smallJsont *self) {
  4118         -: 2774:
  4119        86: 2775:  smallt *o = getsoG(self);
  4120 call    0 returned 100%
  4121         -: 2776:
  4122        86: 2777:  if (o == NULL)
  4123 branch  0 taken 0% (fallthrough)
  4124 branch  1 taken 100%
  4125     #####: 2778:    ret NULL;
  4126         -: 2779:
  4127        86: 2780:  sBytest *B = netSerial(o);
  4128 call    0 returned 100%
  4129         -: 2781:
  4130        86: 2782:  if (!B) {
  4131 branch  0 taken 0% (fallthrough)
  4132 branch  1 taken 100%
  4133     #####: 2783:    ret NULL;
  4134         -: 2784:  }
  4135         -: 2785:
  4136        86: 2786:  createAllocateSmallBytes(r);
  4137 call    0 returned 100%
  4138        86: 2787:  r->B = B;
  4139        86: 2788:  ret r;
  4140         -: 2789:}
  4141         -: 2790:
  4142         -: 2791:// -------------------------------------
  4143         -: 2792:// Deserializers
  4144         -: 2793:
  4145         -: 2794:// level 0
  4146         -: 2795:// like smallJson with ints and length encoded as varints
  4147         -: 2796:
  4148         -: 2797:/**
  4149         -: 2798: * deserializer top function
  4150         -: 2799: */
  4151 function netDeserialLevel0 called 0 returned 0% blocks executed 0%
  4152     #####: 2800:internal smallt* netDeserialLevel0(sBytest *obj) {
  4153     #####: 2801:  smallt   *r = NULL;
  4154     #####: 2802:  double   *D = NULL;
  4155     #####: 2803:  char     *s = NULL;
  4156     #####: 2804:  sBytest  *B = NULL;
  4157         -: 2805:  uint32_t count;
  4158     #####: 2806:  char     *data  = NULL;
  4159         -: 2807:
  4160     #####: 2808:  switch(obj->data & 0xF) {
  4161 branch  0 never executed
  4162 branch  1 never executed
  4163 branch  2 never executed
  4164 branch  3 never executed
  4165 branch  4 never executed
  4166 branch  5 never executed
  4167 branch  6 never executed
  4168 branch  7 never executed
  4169 branch  8 never executed
  4170         -: 2809:    case S_UNDEFINED:
  4171     #####: 2810:      r = (smallt *) allocSUndefined();
  4172 call    0 never executed
  4173     #####: 2811:      break;
  4174         -: 2812:    case S_BOOL:
  4175     #####: 2813:      r = (smallt *) allocSBool(obj->data & 0x10);
  4176 call    0 never executed
  4177     #####: 2814:      break;
  4178         -: 2815:    case S_DICT:
  4179     #####: 2816:      data = (char *)&(obj->data);
  4180     #####: 2817:      dictNetDeserialLevel0((sDictt **)&r, &data);
  4181 call    0 never executed
  4182     #####: 2818:      break;
  4183         -: 2819:    case S_DOUBLE:
  4184     #####: 2820:      data = &(obj->data)+1;
  4185     #####: 2821:      D = (double *)data;
  4186     #####: 2822:      r = (smallt *) allocSDouble(*D);
  4187 call    0 never executed
  4188     #####: 2823:      break;
  4189         -: 2824:    case S_INT:
  4190     #####: 2825:      data  = &(obj->data);
  4191     #####: 2826:      u64 v = netTypeVarintToUint((u8**)&data);
  4192 call    0 never executed
  4193     #####: 2827:      v = (v >> 1) ^ (~(v & 1) + 1);
  4194     #####: 2828:      r = (smallt *) allocSInt(v);
  4195 call    0 never executed
  4196     #####: 2829:      break;
  4197         -: 2830:    case S_STRING:
  4198     #####: 2831:      s = (char *)&(obj->data)+1;
  4199     #####: 2832:      r = (smallt *) allocSStringTiny(s);
  4200 call    0 never executed
  4201     #####: 2833:      break;
  4202         -: 2834:    case S_ARRAY:
  4203     #####: 2835:      data = (char *)&(obj->data);
  4204     #####: 2836:      arrayNetDeserialLevel0((sArrayt **)&r, &data);
  4205 call    0 never executed
  4206     #####: 2837:      break;
  4207         -: 2838:    case S_BYTES:
  4208     #####: 2839:      B     = allocSBytes();
  4209 call    0 never executed
  4210     #####: 2840:      data  = &(obj->data);
  4211     #####: 2841:      count = netTypeVarintToUint((u8**)&data);
  4212 call    0 never executed
  4213     #####: 2842:      sBytesPushBuffer(&B, data, count);
  4214 call    0 never executed
  4215     #####: 2843:      r = (smallt *)B;
  4216     #####: 2844:      break;
  4217         -: 2845:  }
  4218         -: 2846:
  4219     #####: 2847:  ret r;
  4220         -: 2848:}
  4221         -: 2849:
  4222         -: 2850:/**
  4223         -: 2851: * deserialize dictionary from data
  4224         -: 2852: *
  4225         -: 2853: * a new dictionary is allocated
  4226         -: 2854: *
  4227         -: 2855: * \param
  4228         -: 2856: *    dict dictionary holding the elements
  4229         -: 2857: *    data serialized dictionary
  4230         -: 2858: */
  4231 function dictNetDeserialLevel0 called 0 returned 0% blocks executed 0%
  4232     #####: 2859:internal void dictNetDeserialLevel0(sDictt **dict, char **data) {
  4233     #####: 2860:  sUndefinedt *u = NULL;
  4234     #####: 2861:  sBoolt *bo = NULL;
  4235     #####: 2862:  double *D = NULL;
  4236     #####: 2863:  sDoublet *Do = NULL;
  4237     #####: 2864:  sDictt *d = NULL;
  4238     #####: 2865:  sIntt *io = NULL;
  4239     #####: 2866:  char *s = NULL;
  4240     #####: 2867:  sStringt *so = NULL;
  4241     #####: 2868:  sArrayt *a = NULL;
  4242     #####: 2869:  sBytest *B = NULL;
  4243         -: 2870:  uint32_t count;
  4244         -: 2871:  uint32_t dictCount;
  4245         -: 2872:
  4246     #####: 2873:  dictCount = netTypeVarintToUint((u8**)data);
  4247 call    0 never executed
  4248         -: 2874:
  4249     #####: 2875:  if (!dictCount) {
  4250 branch  0 never executed
  4251 branch  1 never executed
  4252     #####: 2876:    *dict = allocSDict();
  4253 call    0 never executed
  4254     #####: 2877:    ret;
  4255         -: 2878:  }
  4256         -: 2879:
  4257     #####: 2880:  loop(dictCount) {
  4258 branch  0 never executed
  4259 branch  1 never executed
  4260         -: 2881:    char type;
  4261         -: 2882:    char *key;
  4262     #####: 2883:    key    = *data;
  4263     #####: 2884:    *data += strlen(key)+1;
  4264     #####: 2885:    type   = **data;
  4265         -: 2886:
  4266     #####: 2887:    switch(type & 0xF) {
  4267 branch  0 never executed
  4268 branch  1 never executed
  4269 branch  2 never executed
  4270 branch  3 never executed
  4271 branch  4 never executed
  4272 branch  5 never executed
  4273 branch  6 never executed
  4274 branch  7 never executed
  4275 branch  8 never executed
  4276         -: 2888:      case S_UNDEFINED:
  4277     #####: 2889:        (*data)++;
  4278     #####: 2890:        u    = allocSUndefined();
  4279 call    0 never executed
  4280     #####: 2891:        sDictPushTiny(dict, key, (smallt *) u);
  4281 call    0 never executed
  4282     #####: 2892:        break;
  4283         -: 2893:      case S_BOOL:
  4284     #####: 2894:        (*data)++;
  4285     #####: 2895:        bo = allocSBool(type & 0x10);
  4286 call    0 never executed
  4287     #####: 2896:        sDictPushTiny(dict, key, (smallt *) bo);
  4288 call    0 never executed
  4289     #####: 2897:        break;
  4290         -: 2898:      case S_DICT:
  4291     #####: 2899:        d = NULL;
  4292     #####: 2900:        dictNetDeserialLevel0(&d, data);
  4293 call    0 never executed
  4294     #####: 2901:        sDictPushTiny(dict, key, (smallt *) d);
  4295 call    0 never executed
  4296     #####: 2902:        break;
  4297         -: 2903:      case S_DOUBLE:
  4298     #####: 2904:        (*data)++;
  4299     #####: 2905:        D      = (double *)(*data);
  4300     #####: 2906:        *data += sizeof(double);
  4301     #####: 2907:        Do     = allocSDouble(*D);
  4302 call    0 never executed
  4303     #####: 2908:        sDictPushTiny(dict, key, (smallt *) Do);
  4304 call    0 never executed
  4305     #####: 2909:        break;
  4306         -: 2910:      case S_INT: {
  4307     #####: 2911:          u64 v = netTypeVarintToUint((u8**)data);
  4308 call    0 never executed
  4309     #####: 2912:          v = (v >> 1) ^ (~(v & 1) + 1);
  4310     #####: 2913:          io     = allocSInt(v);
  4311 call    0 never executed
  4312     #####: 2914:          sDictPushTiny(dict, key, (smallt *) io);
  4313 call    0 never executed
  4314         -: 2915:        }
  4315     #####: 2916:        break;
  4316         -: 2917:      case S_STRING:
  4317     #####: 2918:        (*data)++;
  4318     #####: 2919:        s      = (char *)(*data);
  4319     #####: 2920:        *data += strlen(s)+1;
  4320     #####: 2921:        so     = allocSStringTiny(s);
  4321 call    0 never executed
  4322     #####: 2922:        sDictPushTiny(dict, key, (smallt *) so);
  4323 call    0 never executed
  4324     #####: 2923:        break;
  4325         -: 2924:      case S_ARRAY:
  4326     #####: 2925:        a = NULL;
  4327     #####: 2926:        arrayNetDeserialLevel0(&a, data);
  4328 call    0 never executed
  4329     #####: 2927:        sDictPushTiny(dict, key, (smallt *) a);
  4330 call    0 never executed
  4331     #####: 2928:        break;
  4332         -: 2929:      case S_BYTES:
  4333     #####: 2930:        B      = allocSBytes();
  4334 call    0 never executed
  4335     #####: 2931:        count  = netTypeVarintToUint((u8**)data);
  4336 call    0 never executed
  4337     #####: 2932:        sBytesPushBuffer(&B, *data, count);
  4338 call    0 never executed
  4339     #####: 2933:        *data += count;
  4340     #####: 2934:        sDictPushTiny(dict, key, (smallt *) B);
  4341 call    0 never executed
  4342     #####: 2935:        break;
  4343         -: 2936:    }
  4344         -: 2937:  }
  4345         -: 2938:}
  4346         -: 2939:
  4347         -: 2940:/**
  4348         -: 2941: * deserialize array from data
  4349         -: 2942: *
  4350         -: 2943: * a new array is allocated
  4351         -: 2944: *
  4352         -: 2945: * \param
  4353         -: 2946: *    array holding the elements
  4354         -: 2947: *    data serialized dictionary
  4355         -: 2948: */
  4356 function arrayNetDeserialLevel0 called 0 returned 0% blocks executed 0%
  4357     #####: 2949:internal void arrayNetDeserialLevel0(sArrayt **array, char **data) {
  4358     #####: 2950:  sUndefinedt *u = NULL;
  4359     #####: 2951:  sBoolt *bo = NULL;
  4360     #####: 2952:  double *D = NULL;
  4361     #####: 2953:  sDoublet *Do = NULL;
  4362     #####: 2954:  sDictt *d = NULL;
  4363     #####: 2955:  sIntt *io = NULL;
  4364     #####: 2956:  char *s = NULL;
  4365     #####: 2957:  sStringt *so = NULL;
  4366     #####: 2958:  sArrayt *a = NULL;
  4367     #####: 2959:  sBytest *B = NULL;
  4368         -: 2960:  uint32_t count;
  4369         -: 2961:  uint32_t arrayCount;
  4370         -: 2962:
  4371     #####: 2963:  arrayCount = netTypeVarintToUint((u8**)data);
  4372 call    0 never executed
  4373         -: 2964:
  4374     #####: 2965:  if (!arrayCount) {
  4375 branch  0 never executed
  4376 branch  1 never executed
  4377     #####: 2966:    *array = allocSArray();;
  4378 call    0 never executed
  4379     #####: 2967:    ret;
  4380         -: 2968:  }
  4381         -: 2969:
  4382     #####: 2970:  loop(arrayCount) {
  4383 branch  0 never executed
  4384 branch  1 never executed
  4385         -: 2971:    char type;
  4386     #####: 2972:    type  = **data;
  4387         -: 2973:
  4388     #####: 2974:    switch(type & 0xF) {
  4389 branch  0 never executed
  4390 branch  1 never executed
  4391 branch  2 never executed
  4392 branch  3 never executed
  4393 branch  4 never executed
  4394 branch  5 never executed
  4395 branch  6 never executed
  4396 branch  7 never executed
  4397 branch  8 never executed
  4398         -: 2975:      case S_UNDEFINED:
  4399     #####: 2976:        (*data)++;
  4400     #####: 2977:        u = allocSUndefined();
  4401 call    0 never executed
  4402     #####: 2978:        sArrayPushTiny(array, (smallt *) u);
  4403 call    0 never executed
  4404     #####: 2979:        break;
  4405         -: 2980:      case S_BOOL:
  4406     #####: 2981:        (*data)++;
  4407     #####: 2982:        bo     = allocSBool(type & 0x10);
  4408 call    0 never executed
  4409     #####: 2983:        sArrayPushTiny(array, (smallt *) bo);
  4410 call    0 never executed
  4411     #####: 2984:        break;
  4412         -: 2985:      case S_DICT:
  4413     #####: 2986:        d = NULL;
  4414     #####: 2987:        dictNetDeserialLevel0(&d, data);
  4415 call    0 never executed
  4416     #####: 2988:        sArrayPushTiny(array, (smallt *) d);
  4417 call    0 never executed
  4418     #####: 2989:        break;
  4419         -: 2990:      case S_DOUBLE:
  4420     #####: 2991:        (*data)++;
  4421     #####: 2992:        D      = (double *)(*data);
  4422     #####: 2993:        *data += sizeof(double);
  4423     #####: 2994:        Do     = allocSDouble(*D);
  4424 call    0 never executed
  4425     #####: 2995:        sArrayPushTiny(array, (smallt *) Do);
  4426 call    0 never executed
  4427     #####: 2996:        break;
  4428         -: 2997:      case S_INT: {
  4429     #####: 2998:          u64 v = netTypeVarintToUint((u8**)data);
  4430 call    0 never executed
  4431     #####: 2999:          v = (v >> 1) ^ (~(v & 1) + 1);
  4432     #####: 3000:          io     = allocSInt(v);
  4433 call    0 never executed
  4434     #####: 3001:          sArrayPushTiny(array, (smallt *) io);
  4435 call    0 never executed
  4436         -: 3002:        }
  4437     #####: 3003:        break;
  4438         -: 3004:      case S_STRING:
  4439     #####: 3005:        (*data)++;
  4440     #####: 3006:        s      = (char *)(*data);
  4441     #####: 3007:        *data += strlen(s)+1;
  4442     #####: 3008:        so     = allocSStringTiny(s);
  4443 call    0 never executed
  4444     #####: 3009:        sArrayPushTiny(array, (smallt *) so);
  4445 call    0 never executed
  4446     #####: 3010:        break;
  4447         -: 3011:      case S_ARRAY:
  4448     #####: 3012:        a = NULL;
  4449     #####: 3013:        arrayNetDeserialLevel0(&a, data);
  4450 call    0 never executed
  4451     #####: 3014:        sArrayPushTiny(array, (smallt *) a);
  4452 call    0 never executed
  4453     #####: 3015:        break;
  4454         -: 3016:      case S_BYTES:
  4455     #####: 3017:        B      = allocSBytes();
  4456 call    0 never executed
  4457     #####: 3018:        count  = netTypeVarintToUint((u8**)data);
  4458 call    0 never executed
  4459     #####: 3019:        sBytesPushBuffer(&B, *data, count);
  4460 call    0 never executed
  4461     #####: 3020:        *data += count;
  4462     #####: 3021:        sArrayPushTiny(array, (smallt *) B);
  4463 call    0 never executed
  4464     #####: 3022:        break;
  4465         -: 3023:    }
  4466         -: 3024:  }
  4467         -: 3025:}
  4468         -: 3026:
  4469 function deserialNetSerialLevel0 called 0 returned 0% blocks executed 0%
  4470     #####: 3027:internal smallJsont* deserialNetSerialLevel0(smallJsont *self, smallBytest *data) {
  4471         -: 3028:
  4472     #####: 3029:  if (!data or !data->B or !data->B->count) {
  4473 branch  0 never executed
  4474 branch  1 never executed
  4475 branch  2 never executed
  4476 branch  3 never executed
  4477 branch  4 never executed
  4478 branch  5 never executed
  4479     #####: 3030:    ret self;
  4480         -: 3031:  }
  4481         -: 3032:
  4482     #####: 3033:  smallt *o = netDeserialLevel0(data->B);
  4483 call    0 never executed
  4484         -: 3034:
  4485     #####: 3035:  if (!o) {
  4486 branch  0 never executed
  4487 branch  1 never executed
  4488     #####: 3036:    ret self;
  4489         -: 3037:  }
  4490         -: 3038:
  4491     #####: 3039:  freeG(self);
  4492 call    0 never executed
  4493         -: 3040:
  4494     #####: 3041:  setsoG(self, o);
  4495 call    0 never executed
  4496         -: 3042:
  4497     #####: 3043:  ret self;
  4498         -: 3044:}
  4499         -: 3045:
  4500         -: 3046:// level 1
  4501         -: 3047:// like level 0 with type encoded in nibbles and bools are packed
  4502         -: 3048:
  4503         -: 3049:/**
  4504         -: 3050: * deserializer top function
  4505         -: 3051: */
  4506 function netDeserialLevel1 called 0 returned 0% blocks executed 0%
  4507     #####: 3052:internal smallt* netDeserialLevel1(sBytest *obj) {
  4508     #####: 3053:  smallt   *r = NULL;
  4509     #####: 3054:  double   *D = NULL;
  4510     #####: 3055:  char     *s = NULL;
  4511     #####: 3056:  sBytest  *B = NULL;
  4512         -: 3057:  uint32_t count;
  4513     #####: 3058:  char     *data  = NULL;
  4514     #####: 3059:  contextt ctx = {.nibble=lowNbl, .nblAddr=NULL, .boolShift = 0, .boolAddr=NULL};
  4515         -: 3060:
  4516     #####: 3061:  switch(obj->data & 0xF) {
  4517 branch  0 never executed
  4518 branch  1 never executed
  4519 branch  2 never executed
  4520 branch  3 never executed
  4521 branch  4 never executed
  4522 branch  5 never executed
  4523 branch  6 never executed
  4524 branch  7 never executed
  4525 branch  8 never executed
  4526         -: 3062:    case S_UNDEFINED:
  4527     #####: 3063:      r = (smallt *) allocSUndefined();
  4528 call    0 never executed
  4529     #####: 3064:      break;
  4530         -: 3065:    case S_BOOL:
  4531     #####: 3066:      r = (smallt *) allocSBool(obj->data & 0x10);
  4532 call    0 never executed
  4533     #####: 3067:      break;
  4534         -: 3068:    case S_DICT:
  4535     #####: 3069:      data     = (char *)&(obj->data);
  4536         -: 3070:      //debug - ctx.dbuf = (u8*) data;
  4537     #####: 3071:      dictNetDeserialLevel1((sDictt **)&r, (u8**)&data, &ctx);
  4538 call    0 never executed
  4539     #####: 3072:      break;
  4540         -: 3073:    case S_DOUBLE:
  4541     #####: 3074:      data = &(obj->data)+1;
  4542     #####: 3075:      D = (double *)data;
  4543     #####: 3076:      r = (smallt *) allocSDouble(*D);
  4544 call    0 never executed
  4545     #####: 3077:      break;
  4546         -: 3078:    case S_INT:
  4547     #####: 3079:      data  = &(obj->data);
  4548     #####: 3080:      u64 v = netTypeVarintToUint((u8**)&data);
  4549 call    0 never executed
  4550     #####: 3081:      v = (v >> 1) ^ (~(v & 1) + 1);
  4551     #####: 3082:      r = (smallt *) allocSInt(v);
  4552 call    0 never executed
  4553     #####: 3083:      break;
  4554         -: 3084:    case S_STRING:
  4555     #####: 3085:      s = (char *)&(obj->data)+1;
  4556     #####: 3086:      r = (smallt *) allocSStringTiny(s);
  4557 call    0 never executed
  4558     #####: 3087:      break;
  4559         -: 3088:    case S_ARRAY:
  4560     #####: 3089:      data = (char *)&(obj->data);
  4561         -: 3090:      //debug - ctx.dbuf = (u8*) data;
  4562     #####: 3091:      arrayNetDeserialLevel1((sArrayt **)&r, (u8**)&data, &ctx);
  4563 call    0 never executed
  4564     #####: 3092:      break;
  4565         -: 3093:    case S_BYTES:
  4566     #####: 3094:      B     = allocSBytes();
  4567 call    0 never executed
  4568     #####: 3095:      data  = &(obj->data);
  4569     #####: 3096:      count = netTypeVarintToUint((u8**)&data);
  4570 call    0 never executed
  4571     #####: 3097:      sBytesPushBuffer(&B, data, count);
  4572 call    0 never executed
  4573     #####: 3098:      r = (smallt *)B;
  4574     #####: 3099:      break;
  4575         -: 3100:  }
  4576         -: 3101:
  4577     #####: 3102:  ret r;
  4578         -: 3103:}
  4579         -: 3104:
  4580         -: 3105:/**
  4581         -: 3106: * deserialize dictionary from data
  4582         -: 3107: *
  4583         -: 3108: * a new dictionary is allocated
  4584         -: 3109: *
  4585         -: 3110: * \param
  4586         -: 3111: *    dict dictionary holding the elements
  4587         -: 3112: *    data serialized dictionary
  4588         -: 3113: */
  4589 function dictNetDeserialLevel1 called 0 returned 0% blocks executed 0%
  4590     #####: 3114:internal void dictNetDeserialLevel1(sDictt **dict, u8 **data, contextt *ctx) {
  4591     #####: 3115:  sUndefinedt *u = NULL;
  4592     #####: 3116:  sBoolt *bo = NULL;
  4593     #####: 3117:  double *D = NULL;
  4594     #####: 3118:  sDoublet *Do = NULL;
  4595     #####: 3119:  sDictt *d = NULL;
  4596     #####: 3120:  sIntt *io = NULL;
  4597     #####: 3121:  char *s = NULL;
  4598     #####: 3122:  sStringt *so = NULL;
  4599     #####: 3123:  sArrayt *a = NULL;
  4600     #####: 3124:  sBytest *B = NULL;
  4601         -: 3125:  uint32_t count;
  4602         -: 3126:  uint32_t dictCount;
  4603         -: 3127:
  4604     #####: 3128:  if (ctx->nibble == lowNbl) {
  4605 branch  0 never executed
  4606 branch  1 never executed
  4607     #####: 3129:    dictCount = netTypeVarintToUint(data);
  4608 call    0 never executed
  4609         -: 3130:  }
  4610         -: 3131:  else {
  4611         -: 3132:    // high nibble
  4612         -: 3133:    // type = *(ctx->dbuf + ctx->nblOffset) >> 4;
  4613         -: 3134:    #define readTypeInHighNbl\
  4614         -: 3135:    ctx->nibble  = lowNbl;\
  4615         -: 3136:    if (ctx->nblAddr == *data)\
  4616         -: 3137:      /* data points to the type, next byte is count */\
  4617         -: 3138:      (*data)++
  4618     #####: 3139:    readTypeInHighNbl;
  4619 branch  0 never executed
  4620 branch  1 never executed
  4621     #####: 3140:    dictCount = varintToUint(data);
  4622 call    0 never executed
  4623         -: 3141:  }
  4624         -: 3142:
  4625     #####: 3143:  if (!dictCount) {
  4626 branch  0 never executed
  4627 branch  1 never executed
  4628     #####: 3144:    *dict = allocSDict();
  4629 call    0 never executed
  4630     #####: 3145:    ret;
  4631         -: 3146:  }
  4632         -: 3147:
  4633     #####: 3148:  loop(dictCount) {
  4634 branch  0 never executed
  4635 branch  1 never executed
  4636     #####: 3149:    char *key  = (char*)*data;
  4637     #####: 3150:    *data     += strlen(key)+1;
  4638         -: 3151:    char type;
  4639     #####: 3152:    if (ctx->nibble == lowNbl) {
  4640 branch  0 never executed
  4641 branch  1 never executed
  4642     #####: 3153:      type = (**data) & 0xF;
  4643         -: 3154:    }
  4644         -: 3155:    else {
  4645         -: 3156:      // high nibble
  4646     #####: 3157:      type = (*ctx->nblAddr) >> 4;
  4647         -: 3158:    }
  4648         -: 3159:
  4649     #####: 3160:    switch(type) {
  4650 branch  0 never executed
  4651 branch  1 never executed
  4652 branch  2 never executed
  4653 branch  3 never executed
  4654 branch  4 never executed
  4655 branch  5 never executed
  4656 branch  6 never executed
  4657 branch  7 never executed
  4658 branch  8 never executed
  4659         -: 3161:      case S_UNDEFINED:
  4660     #####: 3162:        if (ctx->nibble == lowNbl) {
  4661 branch  0 never executed
  4662 branch  1 never executed
  4663         -: 3163:          #define readTypeOnly\
  4664         -: 3164:          ctx->nibble  = highNbl;\
  4665         -: 3165:          ctx->nblAddr = *data;\
  4666         -: 3166:          (*data)++
  4667     #####: 3167:          readTypeOnly;
  4668         -: 3168:        }
  4669         -: 3169:        else {
  4670         -: 3170:          // high nibble
  4671     #####: 3171:          readTypeInHighNbl;
  4672 branch  0 never executed
  4673 branch  1 never executed
  4674         -: 3172:        }
  4675     #####: 3173:        u = allocSUndefined();
  4676 call    0 never executed
  4677     #####: 3174:        sDictPushTiny(dict, key, (smallt *) u);
  4678 call    0 never executed
  4679     #####: 3175:        break;
  4680         -: 3176:      case S_BOOL:
  4681     #####: 3177:        if (!ctx->boolAddr) {
  4682 branch  0 never executed
  4683 branch  1 never executed
  4684         -: 3178:          // new packed bools
  4685     #####: 3179:          if (ctx->nibble == lowNbl) {
  4686 branch  0 never executed
  4687 branch  1 never executed
  4688         -: 3180:            #define read4bPackedBool\
  4689         -: 3181:            ctx->boolShift  = 5;\
  4690         -: 3182:            ctx->boolAddr   = *data;\
  4691         -: 3183:            (*data)++
  4692     #####: 3184:            read4bPackedBool;
  4693     #####: 3185:            bo = allocSBool((*ctx->boolAddr) & 0x10);
  4694 call    0 never executed
  4695         -: 3186:          }
  4696         -: 3187:          else {
  4697         -: 3188:            // high nibble
  4698     #####: 3189:            readTypeInHighNbl;
  4699 branch  0 never executed
  4700 branch  1 never executed
  4701         -: 3190:            #define read8bPackedBool\
  4702         -: 3191:            ctx->boolShift  = 1;\
  4703         -: 3192:            ctx->boolAddr   = *data;\
  4704         -: 3193:            (*data)++
  4705     #####: 3194:            read8bPackedBool;
  4706     #####: 3195:            bo = allocSBool((*ctx->boolAddr) & 0x1);
  4707 call    0 never executed
  4708         -: 3196:          }
  4709         -: 3197:        }
  4710         -: 3198:        else {
  4711         -: 3199:          // there was a bool before this one, read bits in nibbles
  4712     #####: 3200:          if (ctx->nibble == lowNbl) {
  4713 branch  0 never executed
  4714 branch  1 never executed
  4715     #####: 3201:            if (ctx->boolShift == 8) {
  4716 branch  0 never executed
  4717 branch  1 never executed
  4718     #####: 3202:              read4bPackedBool;
  4719     #####: 3203:              bo = allocSBool((*ctx->boolAddr) & 0x10);
  4720 call    0 never executed
  4721         -: 3204:            }
  4722         -: 3205:            else {
  4723     #####: 3206:              readTypeOnly;
  4724     #####: 3207:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  4725 call    0 never executed
  4726         -: 3208:            }
  4727         -: 3209:          }
  4728         -: 3210:          else {
  4729         -: 3211:            // high nibble
  4730     #####: 3212:            readTypeInHighNbl;
  4731 branch  0 never executed
  4732 branch  1 never executed
  4733     #####: 3213:            if (ctx->boolShift == 8) {
  4734 branch  0 never executed
  4735 branch  1 never executed
  4736     #####: 3214:              read8bPackedBool;
  4737     #####: 3215:              bo = allocSBool((*ctx->boolAddr) & 0x1);
  4738 call    0 never executed
  4739         -: 3216:            }
  4740         -: 3217:            else {
  4741         -: 3218:              // high nibble
  4742     #####: 3219:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  4743 call    0 never executed
  4744         -: 3220:            }
  4745         -: 3221:          }
  4746         -: 3222:        }
  4747     #####: 3223:        sDictPushTiny(dict, key, (smallt *) bo);
  4748 call    0 never executed
  4749     #####: 3224:        break;
  4750         -: 3225:      case S_DICT:
  4751     #####: 3226:        d = NULL;
  4752     #####: 3227:        dictNetDeserialLevel1(&d, data, ctx);
  4753 call    0 never executed
  4754     #####: 3228:        sDictPushTiny(dict, key, (smallt *) d);
  4755 call    0 never executed
  4756     #####: 3229:        break;
  4757         -: 3230:      case S_DOUBLE:
  4758     #####: 3231:        if (ctx->nibble == lowNbl) {
  4759 branch  0 never executed
  4760 branch  1 never executed
  4761     #####: 3232:          readTypeOnly;
  4762         -: 3233:        }
  4763         -: 3234:        else {
  4764         -: 3235:          // high nibble
  4765     #####: 3236:          readTypeInHighNbl;
  4766 branch  0 never executed
  4767 branch  1 never executed
  4768         -: 3237:        }
  4769     #####: 3238:        D      = (double *)(*data);
  4770     #####: 3239:        *data += sizeof(double);
  4771     #####: 3240:        Do     = allocSDouble(*D);
  4772 call    0 never executed
  4773     #####: 3241:        sDictPushTiny(dict, key, (smallt *) Do);
  4774 call    0 never executed
  4775     #####: 3242:        break;
  4776         -: 3243:      case S_INT: {
  4777         -: 3244:          u64 v;
  4778     #####: 3245:          if (ctx->nibble == lowNbl) {
  4779 branch  0 never executed
  4780 branch  1 never executed
  4781     #####: 3246:            v = netTypeVarintToUint((u8**)data);
  4782 call    0 never executed
  4783         -: 3247:          }
  4784         -: 3248:          else {
  4785         -: 3249:            // high nibble
  4786     #####: 3250:            readTypeInHighNbl;
  4787 branch  0 never executed
  4788 branch  1 never executed
  4789     #####: 3251:            v = varintToUint(data);
  4790 call    0 never executed
  4791         -: 3252:          }
  4792     #####: 3253:          v  = (v >> 1) ^ (~(v & 1) + 1);
  4793     #####: 3254:          io = allocSInt(v);
  4794 call    0 never executed
  4795     #####: 3255:          sDictPushTiny(dict, key, (smallt *) io);
  4796 call    0 never executed
  4797         -: 3256:        }
  4798     #####: 3257:        break;
  4799         -: 3258:      case S_STRING:
  4800     #####: 3259:        if (ctx->nibble == lowNbl) {
  4801 branch  0 never executed
  4802 branch  1 never executed
  4803     #####: 3260:          readTypeOnly;
  4804         -: 3261:        }
  4805         -: 3262:        else {
  4806         -: 3263:          // high nibble
  4807     #####: 3264:          readTypeInHighNbl;
  4808 branch  0 never executed
  4809 branch  1 never executed
  4810         -: 3265:        }
  4811     #####: 3266:        s      = (char *)(*data);
  4812     #####: 3267:        *data += strlen(s)+1;
  4813     #####: 3268:        so     = allocSStringTiny(s);
  4814 call    0 never executed
  4815     #####: 3269:        sDictPushTiny(dict, key, (smallt *) so);
  4816 call    0 never executed
  4817     #####: 3270:        break;
  4818         -: 3271:      case S_ARRAY:
  4819     #####: 3272:        a = NULL;
  4820     #####: 3273:        arrayNetDeserialLevel1(&a, data, ctx);
  4821 call    0 never executed
  4822     #####: 3274:        sDictPushTiny(dict, key, (smallt *) a);
  4823 call    0 never executed
  4824     #####: 3275:        break;
  4825         -: 3276:      case S_BYTES:
  4826     #####: 3277:        B      = allocSBytes();
  4827 call    0 never executed
  4828     #####: 3278:        if (ctx->nibble == lowNbl) {
  4829 branch  0 never executed
  4830 branch  1 never executed
  4831     #####: 3279:          count  = netTypeVarintToUint((u8**)data);
  4832 call    0 never executed
  4833         -: 3280:        }
  4834         -: 3281:        else {
  4835         -: 3282:          // high nibble
  4836     #####: 3283:          readTypeInHighNbl;
  4837 branch  0 never executed
  4838 branch  1 never executed
  4839     #####: 3284:          count  = varintToUint((u8**)data);
  4840 call    0 never executed
  4841         -: 3285:        }
  4842     #####: 3286:        sBytesPushBuffer(&B, *data, count);
  4843 call    0 never executed
  4844     #####: 3287:        *data += count;
  4845     #####: 3288:        sDictPushTiny(dict, key, (smallt *) B);
  4846 call    0 never executed
  4847     #####: 3289:        break;
  4848         -: 3290:    }
  4849         -: 3291:  }
  4850         -: 3292:}
  4851         -: 3293:
  4852         -: 3294:/**
  4853         -: 3295: * deserialize array from data
  4854         -: 3296: *
  4855         -: 3297: * a new array is allocated
  4856         -: 3298: *
  4857         -: 3299: * \param
  4858         -: 3300: *    array holding the elements
  4859         -: 3301: *    data serialized dictionary
  4860         -: 3302: */
  4861 function arrayNetDeserialLevel1 called 0 returned 0% blocks executed 0%
  4862     #####: 3303:internal void arrayNetDeserialLevel1(sArrayt **array, u8 **data, contextt *ctx) {
  4863     #####: 3304:  sUndefinedt *u = NULL;
  4864     #####: 3305:  sBoolt *bo = NULL;
  4865     #####: 3306:  double *D = NULL;
  4866     #####: 3307:  sDoublet *Do = NULL;
  4867     #####: 3308:  sDictt *d = NULL;
  4868     #####: 3309:  sIntt *io = NULL;
  4869     #####: 3310:  char *s = NULL;
  4870     #####: 3311:  sStringt *so = NULL;
  4871     #####: 3312:  sArrayt *a = NULL;
  4872     #####: 3313:  sBytest *B = NULL;
  4873         -: 3314:  uint32_t count;
  4874         -: 3315:  uint32_t arrayCount;
  4875         -: 3316:
  4876     #####: 3317:  if (ctx->nibble == lowNbl) {
  4877 branch  0 never executed
  4878 branch  1 never executed
  4879     #####: 3318:    arrayCount = netTypeVarintToUint(data);
  4880 call    0 never executed
  4881         -: 3319:  }
  4882         -: 3320:  else {
  4883         -: 3321:    // high nibble
  4884     #####: 3322:    readTypeInHighNbl;
  4885 branch  0 never executed
  4886 branch  1 never executed
  4887     #####: 3323:    arrayCount = varintToUint(data);
  4888 call    0 never executed
  4889         -: 3324:  }
  4890         -: 3325:
  4891     #####: 3326:  if (!arrayCount) {
  4892 branch  0 never executed
  4893 branch  1 never executed
  4894     #####: 3327:    *array = allocSArray();;
  4895 call    0 never executed
  4896     #####: 3328:    ret;
  4897         -: 3329:  }
  4898         -: 3330:
  4899     #####: 3331:  loop(arrayCount) {
  4900 branch  0 never executed
  4901 branch  1 never executed
  4902         -: 3332:    char type;
  4903     #####: 3333:    if (ctx->nibble == lowNbl) {
  4904 branch  0 never executed
  4905 branch  1 never executed
  4906     #####: 3334:      type = (**data) & 0xF;
  4907         -: 3335:    }
  4908         -: 3336:    else {
  4909         -: 3337:      // high nibble
  4910     #####: 3338:      type = (*ctx->nblAddr) >> 4;
  4911         -: 3339:    }
  4912         -: 3340:
  4913     #####: 3341:    switch(type) {
  4914 branch  0 never executed
  4915 branch  1 never executed
  4916 branch  2 never executed
  4917 branch  3 never executed
  4918 branch  4 never executed
  4919 branch  5 never executed
  4920 branch  6 never executed
  4921 branch  7 never executed
  4922 branch  8 never executed
  4923         -: 3342:      case S_UNDEFINED:
  4924     #####: 3343:        if (ctx->nibble == lowNbl) {
  4925 branch  0 never executed
  4926 branch  1 never executed
  4927     #####: 3344:          readTypeOnly;
  4928         -: 3345:        }
  4929         -: 3346:        else {
  4930         -: 3347:          // high nibble
  4931     #####: 3348:          readTypeInHighNbl;
  4932 branch  0 never executed
  4933 branch  1 never executed
  4934         -: 3349:        }
  4935     #####: 3350:        u = allocSUndefined();
  4936 call    0 never executed
  4937     #####: 3351:        sArrayPushTiny(array, (smallt *) u);
  4938 call    0 never executed
  4939     #####: 3352:        break;
  4940         -: 3353:      case S_BOOL:
  4941     #####: 3354:        if (!ctx->boolAddr) {
  4942 branch  0 never executed
  4943 branch  1 never executed
  4944         -: 3355:          // new packed bools
  4945     #####: 3356:          if (ctx->nibble == lowNbl) {
  4946 branch  0 never executed
  4947 branch  1 never executed
  4948     #####: 3357:            read4bPackedBool;
  4949     #####: 3358:            bo = allocSBool((*ctx->boolAddr) & 0x10);
  4950 call    0 never executed
  4951         -: 3359:          }
  4952         -: 3360:          else {
  4953         -: 3361:            // high nibble
  4954     #####: 3362:            readTypeInHighNbl;
  4955 branch  0 never executed
  4956 branch  1 never executed
  4957     #####: 3363:            read8bPackedBool;
  4958     #####: 3364:            bo = allocSBool((*ctx->boolAddr) & 0x1);
  4959 call    0 never executed
  4960         -: 3365:          }
  4961         -: 3366:        }
  4962         -: 3367:        else {
  4963         -: 3368:          // there was a bool before this one, read bits in nibbles
  4964     #####: 3369:          if (ctx->nibble == lowNbl) {
  4965 branch  0 never executed
  4966 branch  1 never executed
  4967     #####: 3370:            if (ctx->boolShift == 8) {
  4968 branch  0 never executed
  4969 branch  1 never executed
  4970     #####: 3371:              read4bPackedBool;
  4971     #####: 3372:              bo = allocSBool((*ctx->boolAddr) & 0x10);
  4972 call    0 never executed
  4973         -: 3373:            }
  4974         -: 3374:            else {
  4975     #####: 3375:              readTypeOnly;
  4976     #####: 3376:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  4977 call    0 never executed
  4978         -: 3377:            }
  4979         -: 3378:          }
  4980         -: 3379:          else {
  4981         -: 3380:            // high nibble
  4982     #####: 3381:            readTypeInHighNbl;
  4983 branch  0 never executed
  4984 branch  1 never executed
  4985     #####: 3382:            if (ctx->boolShift == 8) {
  4986 branch  0 never executed
  4987 branch  1 never executed
  4988     #####: 3383:              read8bPackedBool;
  4989     #####: 3384:              bo = allocSBool((*ctx->boolAddr) & 0x1);
  4990 call    0 never executed
  4991         -: 3385:            }
  4992         -: 3386:            else {
  4993     #####: 3387:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  4994 call    0 never executed
  4995         -: 3388:            }
  4996         -: 3389:          }
  4997         -: 3390:        }
  4998     #####: 3391:        sArrayPushTiny(array, (smallt *) bo);
  4999 call    0 never executed
  5000     #####: 3392:        break;
  5001         -: 3393:      case S_DICT:
  5002     #####: 3394:        d = NULL;
  5003     #####: 3395:        dictNetDeserialLevel1(&d, data, ctx);
  5004 call    0 never executed
  5005     #####: 3396:        sArrayPushTiny(array, (smallt *) d);
  5006 call    0 never executed
  5007     #####: 3397:        break;
  5008         -: 3398:      case S_DOUBLE:
  5009     #####: 3399:        if (ctx->nibble == lowNbl) {
  5010 branch  0 never executed
  5011 branch  1 never executed
  5012     #####: 3400:          readTypeOnly;
  5013         -: 3401:        }
  5014         -: 3402:        else {
  5015         -: 3403:          // high nibble
  5016     #####: 3404:          readTypeInHighNbl;
  5017 branch  0 never executed
  5018 branch  1 never executed
  5019         -: 3405:        }
  5020     #####: 3406:        D      = (double *)(*data);
  5021     #####: 3407:        *data += sizeof(double);
  5022     #####: 3408:        Do     = allocSDouble(*D);
  5023 call    0 never executed
  5024     #####: 3409:        sArrayPushTiny(array, (smallt *) Do);
  5025 call    0 never executed
  5026     #####: 3410:        break;
  5027         -: 3411:      case S_INT: {
  5028         -: 3412:          u64 v;
  5029     #####: 3413:          if (ctx->nibble == lowNbl) {
  5030 branch  0 never executed
  5031 branch  1 never executed
  5032     #####: 3414:            v = netTypeVarintToUint((u8**)data);
  5033 call    0 never executed
  5034         -: 3415:          }
  5035         -: 3416:          else {
  5036         -: 3417:            // high nibble
  5037     #####: 3418:            readTypeInHighNbl;
  5038 branch  0 never executed
  5039 branch  1 never executed
  5040     #####: 3419:            v = varintToUint(data);
  5041 call    0 never executed
  5042         -: 3420:          }
  5043     #####: 3421:          v  = (v >> 1) ^ (~(v & 1) + 1);
  5044     #####: 3422:          io = allocSInt(v);
  5045 call    0 never executed
  5046     #####: 3423:          sArrayPushTiny(array, (smallt *) io);
  5047 call    0 never executed
  5048         -: 3424:        }
  5049     #####: 3425:        break;
  5050         -: 3426:      case S_STRING:
  5051     #####: 3427:        if (ctx->nibble == lowNbl) {
  5052 branch  0 never executed
  5053 branch  1 never executed
  5054     #####: 3428:          readTypeOnly;
  5055         -: 3429:        }
  5056         -: 3430:        else {
  5057         -: 3431:          // high nibble
  5058     #####: 3432:          readTypeInHighNbl;
  5059 branch  0 never executed
  5060 branch  1 never executed
  5061         -: 3433:        }
  5062     #####: 3434:        s      = (char *)(*data);
  5063     #####: 3435:        *data += strlen(s)+1;
  5064     #####: 3436:        so     = allocSStringTiny(s);
  5065 call    0 never executed
  5066     #####: 3437:        sArrayPushTiny(array, (smallt *) so);
  5067 call    0 never executed
  5068     #####: 3438:        break;
  5069         -: 3439:      case S_ARRAY:
  5070     #####: 3440:        a = NULL;
  5071     #####: 3441:        arrayNetDeserialLevel1(&a, data, ctx);
  5072 call    0 never executed
  5073     #####: 3442:        sArrayPushTiny(array, (smallt *) a);
  5074 call    0 never executed
  5075     #####: 3443:        break;
  5076         -: 3444:      case S_BYTES:
  5077     #####: 3445:        B      = allocSBytes();
  5078 call    0 never executed
  5079     #####: 3446:        if (ctx->nibble == lowNbl) {
  5080 branch  0 never executed
  5081 branch  1 never executed
  5082     #####: 3447:          count  = netTypeVarintToUint((u8**)data);
  5083 call    0 never executed
  5084         -: 3448:        }
  5085         -: 3449:        else {
  5086         -: 3450:          // high nibble
  5087     #####: 3451:          readTypeInHighNbl;
  5088 branch  0 never executed
  5089 branch  1 never executed
  5090     #####: 3452:          count  = varintToUint((u8**)data);
  5091 call    0 never executed
  5092         -: 3453:        }
  5093     #####: 3454:        sBytesPushBuffer(&B, *data, count);
  5094 call    0 never executed
  5095     #####: 3455:        *data += count;
  5096     #####: 3456:        sArrayPushTiny(array, (smallt *) B);
  5097 call    0 never executed
  5098     #####: 3457:        break;
  5099         -: 3458:    }
  5100         -: 3459:  }
  5101         -: 3460:}
  5102         -: 3461:
  5103 function deserialNetSerialLevel1 called 0 returned 0% blocks executed 0%
  5104     #####: 3462:internal smallJsont* deserialNetSerialLevel1(smallJsont *self, smallBytest *data) {
  5105         -: 3463:
  5106     #####: 3464:  if (!data or !data->B or !data->B->count) {
  5107 branch  0 never executed
  5108 branch  1 never executed
  5109 branch  2 never executed
  5110 branch  3 never executed
  5111 branch  4 never executed
  5112 branch  5 never executed
  5113     #####: 3465:    ret self;
  5114         -: 3466:  }
  5115         -: 3467:
  5116     #####: 3468:  smallt *o = netDeserialLevel1(data->B);
  5117 call    0 never executed
  5118         -: 3469:
  5119     #####: 3470:  if (!o) {
  5120 branch  0 never executed
  5121 branch  1 never executed
  5122     #####: 3471:    ret self;
  5123         -: 3472:  }
  5124         -: 3473:
  5125     #####: 3474:  freeG(self);
  5126 call    0 never executed
  5127         -: 3475:
  5128     #####: 3476:  setsoG(self, o);
  5129 call    0 never executed
  5130         -: 3477:
  5131     #####: 3478:  ret self;
  5132         -: 3479:}
  5133         -: 3480:
  5134         -: 3481:// level 2
  5135         -: 3482:// like level 1, arrays are set to uniform when all elements are same type
  5136         -: 3483:
  5137         -: 3484:/**
  5138         -: 3485: * deserializer top function
  5139         -: 3486: */
  5140 function netDeserialLevel2 called 0 returned 0% blocks executed 0%
  5141     #####: 3487:internal smallt* netDeserialLevel2(sBytest *obj) {
  5142     #####: 3488:  smallt   *r = NULL;
  5143     #####: 3489:  double   *D = NULL;
  5144     #####: 3490:  char     *s = NULL;
  5145     #####: 3491:  sBytest  *B = NULL;
  5146         -: 3492:  uint32_t count;
  5147     #####: 3493:  char     *data  = NULL;
  5148     #####: 3494:  contextt ctx = {.nibble=lowNbl, .nblAddr=NULL, .boolShift = 0, .boolAddr=NULL};
  5149         -: 3495:
  5150     #####: 3496:  switch(obj->data & 0xF) {
  5151 branch  0 never executed
  5152 branch  1 never executed
  5153 branch  2 never executed
  5154 branch  3 never executed
  5155 branch  4 never executed
  5156 branch  5 never executed
  5157 branch  6 never executed
  5158 branch  7 never executed
  5159 branch  8 never executed
  5160 branch  9 never executed
  5161 branch 10 never executed
  5162         -: 3497:    case S_UNDEFINED:
  5163     #####: 3498:      r = (smallt *) allocSUndefined();
  5164 call    0 never executed
  5165     #####: 3499:      break;
  5166         -: 3500:    case S_BOOL:
  5167     #####: 3501:      r = (smallt *) allocSBool(obj->data & 0x10);
  5168 call    0 never executed
  5169     #####: 3502:      break;
  5170         -: 3503:    case S_DICT:
  5171     #####: 3504:      data     = (char *)&(obj->data);
  5172         -: 3505:      //debug - ctx.dbuf = (u8*) data;
  5173     #####: 3506:      dictNetDeserialLevel2((sDictt **)&r, (u8**)&data, &ctx, /*packed=*/false);
  5174 call    0 never executed
  5175     #####: 3507:      break;
  5176         -: 3508:    case S_DOUBLE:
  5177     #####: 3509:      data = &(obj->data)+1;
  5178     #####: 3510:      D = (double *)data;
  5179     #####: 3511:      r = (smallt *) allocSDouble(*D);
  5180 call    0 never executed
  5181     #####: 3512:      break;
  5182         -: 3513:    case S_INT:
  5183     #####: 3514:      data  = &(obj->data);
  5184     #####: 3515:      u64 v = netTypeVarintToUint((u8**)&data);
  5185 call    0 never executed
  5186     #####: 3516:      v     = (v >> 1) ^ (~(v & 1) + 1);
  5187     #####: 3517:      r = (smallt *) allocSInt(v);
  5188 call    0 never executed
  5189     #####: 3518:      break;
  5190         -: 3519:    case S_STRING:
  5191     #####: 3520:      s = (char *)&(obj->data)+1;
  5192     #####: 3521:      r = (smallt *) allocSStringTiny(s);
  5193 call    0 never executed
  5194     #####: 3522:      break;
  5195         -: 3523:    case S_ARRAY:
  5196     #####: 3524:      data = (char *)&(obj->data);
  5197         -: 3525:      //debug - ctx.dbuf = (u8*) data;
  5198     #####: 3526:      arrayNetDeserialLevel2((sArrayt **)&r, (u8**)&data, &ctx, /*packed=*/false);
  5199 call    0 never executed
  5200     #####: 3527:      break;
  5201         -: 3528:    case S_BYTES:
  5202     #####: 3529:      B     = allocSBytes();
  5203 call    0 never executed
  5204     #####: 3530:      data  = &(obj->data);
  5205     #####: 3531:      count = netTypeVarintToUint((u8**)&data);
  5206 call    0 never executed
  5207     #####: 3532:      sBytesPushBuffer(&B, data, count);
  5208 call    0 never executed
  5209     #####: 3533:      r = (smallt *)B;
  5210     #####: 3534:      break;
  5211         -: 3535:    case UNIFORM_DICT:
  5212     #####: 3536:      data     = (char *)&(obj->data);
  5213         -: 3537:      //debug - ctx.dbuf = (u8*) data;
  5214     #####: 3538:      uniformDictNetDeserialLevel2((sDictt **)&r, (u8**)&data, &ctx, /*packed=*/false);
  5215 call    0 never executed
  5216     #####: 3539:      break;
  5217         -: 3540:    case UNIFORM_ARRAY:
  5218     #####: 3541:      data     = (char *)&(obj->data);
  5219         -: 3542:      //debug - ctx.dbuf = (u8*) data;
  5220     #####: 3543:      uniformArrayNetDeserialLevel2((sArrayt **)&r, (u8**)&data, &ctx, /*packed=*/false);
  5221 call    0 never executed
  5222     #####: 3544:      break;
  5223         -: 3545:  }
  5224         -: 3546:
  5225     #####: 3547:  ret r;
  5226         -: 3548:}
  5227         -: 3549:
  5228         -: 3550:/**
  5229         -: 3551: * deserialize dictionary from data
  5230         -: 3552: *
  5231         -: 3553: * a new dictionary is allocated
  5232         -: 3554: *
  5233         -: 3555: * \param
  5234         -: 3556: *    dict dictionary holding the elements
  5235         -: 3557: *    data serialized dictionary
  5236         -: 3558: */
  5237 function dictNetDeserialLevel2 called 0 returned 0% blocks executed 0%
  5238     #####: 3559:internal void dictNetDeserialLevel2(sDictt **dict, u8 **data, contextt *ctx, bool packed) {
  5239     #####: 3560:  sUndefinedt *u = NULL;
  5240     #####: 3561:  sBoolt *bo = NULL;
  5241     #####: 3562:  double *D = NULL;
  5242     #####: 3563:  sDoublet *Do = NULL;
  5243     #####: 3564:  sDictt *d = NULL;
  5244     #####: 3565:  sIntt *io = NULL;
  5245     #####: 3566:  char *s = NULL;
  5246     #####: 3567:  sStringt *so = NULL;
  5247     #####: 3568:  sArrayt *a = NULL;
  5248     #####: 3569:  sBytest *B = NULL;
  5249         -: 3570:  uint32_t count;
  5250         -: 3571:  uint32_t dictCount;
  5251         -: 3572:
  5252     #####: 3573:  if (packed) {
  5253 branch  0 never executed
  5254 branch  1 never executed
  5255     #####: 3574:    dictCount = varintToUint(data);
  5256 call    0 never executed
  5257         -: 3575:  }
  5258         -: 3576:  else {
  5259     #####: 3577:    if (ctx->nibble == lowNbl) {
  5260 branch  0 never executed
  5261 branch  1 never executed
  5262     #####: 3578:      dictCount = netTypeVarintToUint(data);
  5263 call    0 never executed
  5264         -: 3579:    }
  5265         -: 3580:    else {
  5266         -: 3581:      // high nibble
  5267         -: 3582:      // type = *(ctx->dbuf + ctx->nblOffset) >> 4;
  5268         -: 3583:      #define readTypeInHighNbl\
  5269         -: 3584:      ctx->nibble  = lowNbl;\
  5270         -: 3585:      if (ctx->nblAddr == *data)\
  5271         -: 3586:      /* data points to the type, next byte is count */\
  5272         -: 3587:      (*data)++
  5273     #####: 3588:      readTypeInHighNbl;
  5274 branch  0 never executed
  5275 branch  1 never executed
  5276     #####: 3589:      dictCount = varintToUint(data);
  5277 call    0 never executed
  5278         -: 3590:    }
  5279         -: 3591:  }
  5280         -: 3592:
  5281     #####: 3593:  if (!dictCount) {
  5282 branch  0 never executed
  5283 branch  1 never executed
  5284     #####: 3594:    *dict = allocSDict();
  5285 call    0 never executed
  5286     #####: 3595:    ret;
  5287         -: 3596:  }
  5288         -: 3597:
  5289     #####: 3598:  loop(dictCount) {
  5290 branch  0 never executed
  5291 branch  1 never executed
  5292     #####: 3599:    char *key  = (char*)*data;
  5293     #####: 3600:    *data     += strlen(key)+1;
  5294         -: 3601:    char type;
  5295     #####: 3602:    if (ctx->nibble == lowNbl) {
  5296 branch  0 never executed
  5297 branch  1 never executed
  5298     #####: 3603:      type = (**data) & 0xF;
  5299         -: 3604:    }
  5300         -: 3605:    else {
  5301         -: 3606:      // high nibble
  5302     #####: 3607:      type = (*ctx->nblAddr) >> 4;
  5303         -: 3608:    }
  5304         -: 3609:
  5305     #####: 3610:    switch(type) {
  5306 branch  0 never executed
  5307 branch  1 never executed
  5308 branch  2 never executed
  5309 branch  3 never executed
  5310 branch  4 never executed
  5311 branch  5 never executed
  5312 branch  6 never executed
  5313 branch  7 never executed
  5314 branch  8 never executed
  5315 branch  9 never executed
  5316 branch 10 never executed
  5317         -: 3611:      case S_UNDEFINED:
  5318     #####: 3612:        if (ctx->nibble == lowNbl) {
  5319 branch  0 never executed
  5320 branch  1 never executed
  5321         -: 3613:          #define readTypeOnly\
  5322         -: 3614:          ctx->nibble  = highNbl;\
  5323         -: 3615:          ctx->nblAddr = *data;\
  5324         -: 3616:          (*data)++
  5325     #####: 3617:          readTypeOnly;
  5326         -: 3618:        }
  5327         -: 3619:        else {
  5328         -: 3620:          // high nibble
  5329     #####: 3621:          readTypeInHighNbl;
  5330 branch  0 never executed
  5331 branch  1 never executed
  5332         -: 3622:        }
  5333     #####: 3623:        u = allocSUndefined();
  5334 call    0 never executed
  5335     #####: 3624:        sDictPushTiny(dict, key, (smallt *) u);
  5336 call    0 never executed
  5337     #####: 3625:        break;
  5338         -: 3626:      case S_BOOL:
  5339     #####: 3627:        if (!ctx->boolAddr) {
  5340 branch  0 never executed
  5341 branch  1 never executed
  5342         -: 3628:          // new packed bools
  5343     #####: 3629:          if (ctx->nibble == lowNbl) {
  5344 branch  0 never executed
  5345 branch  1 never executed
  5346         -: 3630:            #define read4bPackedBool\
  5347         -: 3631:            ctx->boolShift  = 5;\
  5348         -: 3632:            ctx->boolAddr   = *data;\
  5349         -: 3633:            (*data)++
  5350     #####: 3634:            read4bPackedBool;
  5351     #####: 3635:            bo = allocSBool((*ctx->boolAddr) & 0x10);
  5352 call    0 never executed
  5353         -: 3636:          }
  5354         -: 3637:          else {
  5355         -: 3638:            // high nibble
  5356     #####: 3639:            readTypeInHighNbl;
  5357 branch  0 never executed
  5358 branch  1 never executed
  5359         -: 3640:            #define read8bPackedBool\
  5360         -: 3641:            ctx->boolShift  = 1;\
  5361         -: 3642:            ctx->boolAddr   = *data;\
  5362         -: 3643:            (*data)++
  5363     #####: 3644:            read8bPackedBool;
  5364     #####: 3645:            bo = allocSBool((*ctx->boolAddr) & 0x1);
  5365 call    0 never executed
  5366         -: 3646:          }
  5367         -: 3647:        }
  5368         -: 3648:        else {
  5369         -: 3649:          // there was a bool before this one, read bits in nibbles
  5370     #####: 3650:          if (ctx->nibble == lowNbl) {
  5371 branch  0 never executed
  5372 branch  1 never executed
  5373     #####: 3651:            if (ctx->boolShift == 8) {
  5374 branch  0 never executed
  5375 branch  1 never executed
  5376     #####: 3652:              read4bPackedBool;
  5377     #####: 3653:              bo = allocSBool((*ctx->boolAddr) & 0x10);
  5378 call    0 never executed
  5379         -: 3654:            }
  5380         -: 3655:            else {
  5381     #####: 3656:              readTypeOnly;
  5382     #####: 3657:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  5383 call    0 never executed
  5384         -: 3658:            }
  5385         -: 3659:          }
  5386         -: 3660:          else {
  5387         -: 3661:            // high nibble
  5388     #####: 3662:            readTypeInHighNbl;
  5389 branch  0 never executed
  5390 branch  1 never executed
  5391     #####: 3663:            if (ctx->boolShift == 8) {
  5392 branch  0 never executed
  5393 branch  1 never executed
  5394     #####: 3664:              read8bPackedBool;
  5395     #####: 3665:              bo = allocSBool((*ctx->boolAddr) & 0x1);
  5396 call    0 never executed
  5397         -: 3666:            }
  5398         -: 3667:            else {
  5399         -: 3668:              // high nibble
  5400     #####: 3669:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  5401 call    0 never executed
  5402         -: 3670:            }
  5403         -: 3671:          }
  5404         -: 3672:        }
  5405     #####: 3673:        sDictPushTiny(dict, key, (smallt *) bo);
  5406 call    0 never executed
  5407     #####: 3674:        break;
  5408         -: 3675:      case S_DICT:
  5409     #####: 3676:        d = NULL;
  5410     #####: 3677:        dictNetDeserialLevel2(&d, data, ctx, /*packed=*/false);
  5411 call    0 never executed
  5412     #####: 3678:        sDictPushTiny(dict, key, (smallt *) d);
  5413 call    0 never executed
  5414     #####: 3679:        break;
  5415         -: 3680:      case S_DOUBLE:
  5416     #####: 3681:        if (ctx->nibble == lowNbl) {
  5417 branch  0 never executed
  5418 branch  1 never executed
  5419     #####: 3682:          readTypeOnly;
  5420         -: 3683:        }
  5421         -: 3684:        else {
  5422         -: 3685:          // high nibble
  5423     #####: 3686:          readTypeInHighNbl;
  5424 branch  0 never executed
  5425 branch  1 never executed
  5426         -: 3687:        }
  5427     #####: 3688:        D      = (double *)(*data);
  5428     #####: 3689:        *data += sizeof(double);
  5429     #####: 3690:        Do     = allocSDouble(*D);
  5430 call    0 never executed
  5431     #####: 3691:        sDictPushTiny(dict, key, (smallt *) Do);
  5432 call    0 never executed
  5433     #####: 3692:        break;
  5434         -: 3693:      case S_INT: {
  5435         -: 3694:          u64 v;
  5436     #####: 3695:          if (ctx->nibble == lowNbl) {
  5437 branch  0 never executed
  5438 branch  1 never executed
  5439     #####: 3696:            v = netTypeVarintToUint((u8**)data);
  5440 call    0 never executed
  5441         -: 3697:          }
  5442         -: 3698:          else {
  5443         -: 3699:            // high nibble
  5444     #####: 3700:            readTypeInHighNbl;
  5445 branch  0 never executed
  5446 branch  1 never executed
  5447     #####: 3701:            v = varintToUint(data);
  5448 call    0 never executed
  5449         -: 3702:          }
  5450     #####: 3703:          v  = (v >> 1) ^ (~(v & 1) + 1);
  5451     #####: 3704:          io = allocSInt(v);
  5452 call    0 never executed
  5453     #####: 3705:          sDictPushTiny(dict, key, (smallt *) io);
  5454 call    0 never executed
  5455         -: 3706:        }
  5456     #####: 3707:        break;
  5457         -: 3708:      case S_STRING:
  5458     #####: 3709:        if (ctx->nibble == lowNbl) {
  5459 branch  0 never executed
  5460 branch  1 never executed
  5461     #####: 3710:          readTypeOnly;
  5462         -: 3711:        }
  5463         -: 3712:        else {
  5464         -: 3713:          // high nibble
  5465     #####: 3714:          readTypeInHighNbl;
  5466 branch  0 never executed
  5467 branch  1 never executed
  5468         -: 3715:        }
  5469     #####: 3716:        s      = (char *)(*data);
  5470     #####: 3717:        *data += strlen(s)+1;
  5471     #####: 3718:        so     = allocSStringTiny(s);
  5472 call    0 never executed
  5473     #####: 3719:        sDictPushTiny(dict, key, (smallt *) so);
  5474 call    0 never executed
  5475     #####: 3720:        break;
  5476         -: 3721:      case S_ARRAY:
  5477     #####: 3722:        a = NULL;
  5478     #####: 3723:        arrayNetDeserialLevel2(&a, data, ctx, /*packed=*/false);
  5479 call    0 never executed
  5480     #####: 3724:        sDictPushTiny(dict, key, (smallt *) a);
  5481 call    0 never executed
  5482     #####: 3725:        break;
  5483         -: 3726:      case S_BYTES:
  5484     #####: 3727:        B      = allocSBytes();
  5485 call    0 never executed
  5486     #####: 3728:        if (ctx->nibble == lowNbl) {
  5487 branch  0 never executed
  5488 branch  1 never executed
  5489     #####: 3729:          count  = netTypeVarintToUint((u8**)data);
  5490 call    0 never executed
  5491         -: 3730:        }
  5492         -: 3731:        else {
  5493         -: 3732:          // high nibble
  5494     #####: 3733:          readTypeInHighNbl;
  5495 branch  0 never executed
  5496 branch  1 never executed
  5497     #####: 3734:          count  = varintToUint((u8**)data);
  5498 call    0 never executed
  5499         -: 3735:        }
  5500     #####: 3736:        sBytesPushBuffer(&B, *data, count);
  5501 call    0 never executed
  5502     #####: 3737:        *data += count;
  5503     #####: 3738:        sDictPushTiny(dict, key, (smallt *) B);
  5504 call    0 never executed
  5505     #####: 3739:        break;
  5506         -: 3740:      case UNIFORM_DICT:
  5507     #####: 3741:        d = NULL;
  5508     #####: 3742:        uniformDictNetDeserialLevel2(&d, data, ctx, /*packed=*/false);
  5509 call    0 never executed
  5510     #####: 3743:        sDictPushTiny(dict, key, (smallt *) d);
  5511 call    0 never executed
  5512     #####: 3744:        break;
  5513         -: 3745:      case UNIFORM_ARRAY:
  5514     #####: 3746:        a = NULL;
  5515     #####: 3747:        uniformArrayNetDeserialLevel2(&a, data, ctx, /*packed=*/false);
  5516 call    0 never executed
  5517     #####: 3748:        sDictPushTiny(dict, key, (smallt *) a);
  5518 call    0 never executed
  5519     #####: 3749:        break;
  5520         -: 3750:    }
  5521         -: 3751:  }
  5522         -: 3752:}
  5523         -: 3753:
  5524         -: 3754:/**
  5525         -: 3755: * deserialize dictionary from data
  5526         -: 3756: *
  5527         -: 3757: * a new dictionary is allocated
  5528         -: 3758: *
  5529         -: 3759: * \param
  5530         -: 3760: *    dict dictionary holding the elements
  5531         -: 3761: *    data serialized dictionary
  5532         -: 3762: */
  5533 function uniformDictNetDeserialLevel2 called 0 returned 0% blocks executed 0%
  5534     #####: 3763:internal void uniformDictNetDeserialLevel2(sDictt **dict, u8 **data, contextt *ctx, bool packed) {
  5535     #####: 3764:  sUndefinedt *u = NULL;
  5536     #####: 3765:  sBoolt *bo = NULL;
  5537     #####: 3766:  double *D = NULL;
  5538     #####: 3767:  sDoublet *Do = NULL;
  5539     #####: 3768:  sDictt *d = NULL;
  5540     #####: 3769:  sIntt *io = NULL;
  5541     #####: 3770:  char *s = NULL;
  5542     #####: 3771:  sStringt *so = NULL;
  5543     #####: 3772:  sArrayt *a = NULL;
  5544     #####: 3773:  sBytest *B = NULL;
  5545         -: 3774:  uint32_t count;
  5546         -: 3775:  uint32_t dictCount;
  5547         -: 3776:  u8 type;
  5548         -: 3777:
  5549     #####: 3778:  if (packed) {
  5550 branch  0 never executed
  5551 branch  1 never executed
  5552     #####: 3779:    type = (**data) & 0xF;
  5553     #####: 3780:    dictCount = netTypeVarintToUint(data);
  5554 call    0 never executed
  5555         -: 3781:  }
  5556         -: 3782:  else {
  5557     #####: 3783:    if (ctx->nibble == lowNbl) {
  5558 branch  0 never executed
  5559 branch  1 never executed
  5560     #####: 3784:      type = (**data) >> 4;
  5561     #####: 3785:      (*data)++;
  5562     #####: 3786:      dictCount = varintToUint(data);
  5563 call    0 never executed
  5564         -: 3787:    }
  5565         -: 3788:    else {
  5566     #####: 3789:      readTypeInHighNbl;
  5567 branch  0 never executed
  5568 branch  1 never executed
  5569     #####: 3790:      type = (**data) & 0xF;
  5570     #####: 3791:      dictCount = netTypeVarintToUint(data);
  5571 call    0 never executed
  5572         -: 3792:    }
  5573         -: 3793:  }
  5574         -: 3794:
  5575     #####: 3795:  if (!dictCount) {
  5576 branch  0 never executed
  5577 branch  1 never executed
  5578     #####: 3796:    *dict = allocSDict();
  5579 call    0 never executed
  5580     #####: 3797:    ret;
  5581         -: 3798:  }
  5582         -: 3799:
  5583         -: 3800:
  5584     #####: 3801:  switch(type) {
  5585 branch  0 never executed
  5586 branch  1 never executed
  5587 branch  2 never executed
  5588 branch  3 never executed
  5589 branch  4 never executed
  5590 branch  5 never executed
  5591 branch  6 never executed
  5592 branch  7 never executed
  5593 branch  8 never executed
  5594 branch  9 never executed
  5595 branch 10 never executed
  5596         -: 3802:    case S_UNDEFINED:
  5597     #####: 3803:      loop(dictCount) {
  5598 branch  0 never executed
  5599 branch  1 never executed
  5600     #####: 3804:        char *key  = (char*)*data;
  5601     #####: 3805:        *data     += strlen(key)+1;
  5602     #####: 3806:        u = allocSUndefined();
  5603 call    0 never executed
  5604     #####: 3807:        sDictPushTiny(dict, key, (smallt *) u);
  5605 call    0 never executed
  5606         -: 3808:      }
  5607     #####: 3809:      break;
  5608         -: 3810:    case S_BOOL:
  5609     #####: 3811:      loop(dictCount) {
  5610 branch  0 never executed
  5611 branch  1 never executed
  5612     #####: 3812:        char *key  = (char*)*data;
  5613     #####: 3813:        *data     += strlen(key)+1;
  5614     #####: 3814:        if (!ctx->boolAddr) {
  5615 branch  0 never executed
  5616 branch  1 never executed
  5617     #####: 3815:          read8bPackedBool;
  5618     #####: 3816:          ctx->boolShift = 0;
  5619         -: 3817:        }
  5620     #####: 3818:        if (ctx->boolShift == 8) {
  5621 branch  0 never executed
  5622 branch  1 never executed
  5623     #####: 3819:          readTypeInHighNbl;
  5624 branch  0 never executed
  5625 branch  1 never executed
  5626     #####: 3820:          read8bPackedBool;
  5627     #####: 3821:          bo = allocSBool((*ctx->boolAddr) & 0x1);
  5628 call    0 never executed
  5629         -: 3822:        }
  5630         -: 3823:        else {
  5631         -: 3824:          // high nibble
  5632     #####: 3825:          readTypeInHighNbl;
  5633 branch  0 never executed
  5634 branch  1 never executed
  5635     #####: 3826:          bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  5636 call    0 never executed
  5637         -: 3827:        }
  5638     #####: 3828:        sDictPushTiny(dict, key, (smallt *) bo);
  5639 call    0 never executed
  5640         -: 3829:      }
  5641     #####: 3830:      break;
  5642         -: 3831:    case S_DICT:
  5643     #####: 3832:      loop(dictCount) {
  5644 branch  0 never executed
  5645 branch  1 never executed
  5646     #####: 3833:        char *key  = (char*)*data;
  5647     #####: 3834:        *data     += strlen(key)+1;
  5648     #####: 3835:        d          = NULL;
  5649     #####: 3836:        dictNetDeserialLevel2(&d, data, ctx, /*packed=*/true);
  5650 call    0 never executed
  5651     #####: 3837:        sDictPushTiny(dict, key, (smallt *) d);
  5652 call    0 never executed
  5653         -: 3838:      }
  5654     #####: 3839:      break;
  5655         -: 3840:    case S_DOUBLE:
  5656     #####: 3841:      loop(dictCount) {
  5657 branch  0 never executed
  5658 branch  1 never executed
  5659     #####: 3842:        char *key  = (char*)*data;
  5660     #####: 3843:        *data     += strlen(key)+1;
  5661     #####: 3844:        D          = (double *)(*data);
  5662     #####: 3845:        *data     += sizeof(double);
  5663     #####: 3846:        Do         = allocSDouble(*D);
  5664 call    0 never executed
  5665     #####: 3847:        sDictPushTiny(dict, key, (smallt *) Do);
  5666 call    0 never executed
  5667         -: 3848:      }
  5668     #####: 3849:      break;
  5669         -: 3850:    case S_INT:
  5670     #####: 3851:      loop(dictCount) {
  5671 branch  0 never executed
  5672 branch  1 never executed
  5673     #####: 3852:        char *key  = (char*)*data;
  5674     #####: 3853:        *data     += strlen(key)+1;
  5675     #####: 3854:        u64 v      = varintToUint(data);
  5676 call    0 never executed
  5677     #####: 3855:        v          = (v >> 1) ^ (~(v & 1) + 1);
  5678     #####: 3856:        io         = allocSInt(v);
  5679 call    0 never executed
  5680     #####: 3857:        sDictPushTiny(dict, key, (smallt *) io);
  5681 call    0 never executed
  5682         -: 3858:      }
  5683     #####: 3859:      break;
  5684         -: 3860:    case S_STRING:
  5685     #####: 3861:      loop(dictCount) {
  5686 branch  0 never executed
  5687 branch  1 never executed
  5688     #####: 3862:        char *key  = (char*)*data;
  5689     #####: 3863:        *data     += strlen(key)+1;
  5690     #####: 3864:        s          = (char *)(*data);
  5691     #####: 3865:        *data     += strlen(s)+1;
  5692     #####: 3866:        so         = allocSStringTiny(s);
  5693 call    0 never executed
  5694     #####: 3867:        sDictPushTiny(dict, key, (smallt *) so);
  5695 call    0 never executed
  5696         -: 3868:      }
  5697     #####: 3869:      break;
  5698         -: 3870:    case S_ARRAY:
  5699     #####: 3871:      loop(dictCount) {
  5700 branch  0 never executed
  5701 branch  1 never executed
  5702     #####: 3872:        char *key  = (char*)*data;
  5703     #####: 3873:        *data     += strlen(key)+1;
  5704     #####: 3874:        a          = NULL;
  5705     #####: 3875:        arrayNetDeserialLevel2(&a, data, ctx, /*packed=*/true);
  5706 call    0 never executed
  5707     #####: 3876:        sDictPushTiny(dict, key, (smallt *) a);
  5708 call    0 never executed
  5709         -: 3877:      }
  5710     #####: 3878:      break;
  5711         -: 3879:    case S_BYTES:
  5712     #####: 3880:      loop(dictCount) {
  5713 branch  0 never executed
  5714 branch  1 never executed
  5715     #####: 3881:        char *key  = (char*)*data;
  5716     #####: 3882:        *data     += strlen(key)+1;
  5717     #####: 3883:        B          = allocSBytes();
  5718 call    0 never executed
  5719     #####: 3884:        count      = varintToUint((u8**)data);
  5720 call    0 never executed
  5721     #####: 3885:        sBytesPushBuffer(&B, *data, count);
  5722 call    0 never executed
  5723     #####: 3886:        *data     += count;
  5724     #####: 3887:        sDictPushTiny(dict, key, (smallt *) B);
  5725 call    0 never executed
  5726         -: 3888:      }
  5727     #####: 3889:      break;
  5728         -: 3890:    case UNIFORM_DICT:
  5729     #####: 3891:      loop(dictCount) {
  5730 branch  0 never executed
  5731 branch  1 never executed
  5732     #####: 3892:        char *key  = (char*)*data;
  5733     #####: 3893:        *data     += strlen(key)+1;
  5734     #####: 3894:        d          = NULL;
  5735     #####: 3895:        uniformDictNetDeserialLevel2(&d, data, ctx, /*packed=*/true);
  5736 call    0 never executed
  5737     #####: 3896:        sDictPushTiny(dict, key, (smallt *) d);
  5738 call    0 never executed
  5739         -: 3897:      }
  5740     #####: 3898:      break;
  5741         -: 3899:    case UNIFORM_ARRAY:
  5742     #####: 3900:      loop(dictCount) {
  5743 branch  0 never executed
  5744 branch  1 never executed
  5745     #####: 3901:        char *key  = (char*)*data;
  5746     #####: 3902:        *data     += strlen(key)+1;
  5747     #####: 3903:        a          = NULL;
  5748     #####: 3904:        uniformArrayNetDeserialLevel2(&a, data, ctx, /*packed=*/true);
  5749 call    0 never executed
  5750     #####: 3905:        sDictPushTiny(dict, key, (smallt *) a);
  5751 call    0 never executed
  5752         -: 3906:      }
  5753     #####: 3907:      break;
  5754         -: 3908:  }
  5755         -: 3909:}
  5756         -: 3910:
  5757         -: 3911:/**
  5758         -: 3912: * deserialize array from data
  5759         -: 3913: *
  5760         -: 3914: * a new array is allocated
  5761         -: 3915: *
  5762         -: 3916: * \param
  5763         -: 3917: *    array holding the elements
  5764         -: 3918: *    data serialized dictionary
  5765         -: 3919: */
  5766 function arrayNetDeserialLevel2 called 0 returned 0% blocks executed 0%
  5767     #####: 3920:internal void arrayNetDeserialLevel2(sArrayt **array, u8 **data, contextt *ctx, bool packed) {
  5768     #####: 3921:  sUndefinedt *u = NULL;
  5769     #####: 3922:  sBoolt *bo = NULL;
  5770     #####: 3923:  double *D = NULL;
  5771     #####: 3924:  sDoublet *Do = NULL;
  5772     #####: 3925:  sDictt *d = NULL;
  5773     #####: 3926:  sIntt *io = NULL;
  5774     #####: 3927:  char *s = NULL;
  5775     #####: 3928:  sStringt *so = NULL;
  5776     #####: 3929:  sArrayt *a = NULL;
  5777     #####: 3930:  sBytest *B = NULL;
  5778         -: 3931:  uint32_t count;
  5779         -: 3932:  uint32_t arrayCount;
  5780         -: 3933:
  5781     #####: 3934:  if (packed) {
  5782 branch  0 never executed
  5783 branch  1 never executed
  5784     #####: 3935:    arrayCount = varintToUint(data);
  5785 call    0 never executed
  5786         -: 3936:  }
  5787         -: 3937:  else {
  5788     #####: 3938:    if (ctx->nibble == lowNbl) {
  5789 branch  0 never executed
  5790 branch  1 never executed
  5791     #####: 3939:      arrayCount = netTypeVarintToUint(data);
  5792 call    0 never executed
  5793         -: 3940:    }
  5794         -: 3941:    else {
  5795         -: 3942:      // high nibble
  5796     #####: 3943:      readTypeInHighNbl;
  5797 branch  0 never executed
  5798 branch  1 never executed
  5799     #####: 3944:      arrayCount = varintToUint(data);
  5800 call    0 never executed
  5801         -: 3945:    }
  5802         -: 3946:  }
  5803         -: 3947:
  5804     #####: 3948:  if (!arrayCount) {
  5805 branch  0 never executed
  5806 branch  1 never executed
  5807     #####: 3949:    *array = allocSArray();;
  5808 call    0 never executed
  5809     #####: 3950:    ret;
  5810         -: 3951:  }
  5811         -: 3952:
  5812     #####: 3953:  loop(arrayCount) {
  5813 branch  0 never executed
  5814 branch  1 never executed
  5815         -: 3954:    char type;
  5816     #####: 3955:    if (ctx->nibble == lowNbl) {
  5817 branch  0 never executed
  5818 branch  1 never executed
  5819     #####: 3956:      type = (**data) & 0xF;
  5820         -: 3957:    }
  5821         -: 3958:    else {
  5822         -: 3959:      // high nibble
  5823     #####: 3960:      type = (*ctx->nblAddr) >> 4;
  5824         -: 3961:    }
  5825         -: 3962:
  5826     #####: 3963:    switch(type) {
  5827 branch  0 never executed
  5828 branch  1 never executed
  5829 branch  2 never executed
  5830 branch  3 never executed
  5831 branch  4 never executed
  5832 branch  5 never executed
  5833 branch  6 never executed
  5834 branch  7 never executed
  5835 branch  8 never executed
  5836 branch  9 never executed
  5837 branch 10 never executed
  5838         -: 3964:      case S_UNDEFINED:
  5839     #####: 3965:        if (ctx->nibble == lowNbl) {
  5840 branch  0 never executed
  5841 branch  1 never executed
  5842     #####: 3966:          readTypeOnly;
  5843         -: 3967:        }
  5844         -: 3968:        else {
  5845         -: 3969:          // high nibble
  5846     #####: 3970:          readTypeInHighNbl;
  5847 branch  0 never executed
  5848 branch  1 never executed
  5849         -: 3971:        }
  5850     #####: 3972:        u = allocSUndefined();
  5851 call    0 never executed
  5852     #####: 3973:        sArrayPushTiny(array, (smallt *) u);
  5853 call    0 never executed
  5854     #####: 3974:        break;
  5855         -: 3975:      case S_BOOL:
  5856     #####: 3976:        if (!ctx->boolAddr) {
  5857 branch  0 never executed
  5858 branch  1 never executed
  5859         -: 3977:          // new packed bools
  5860     #####: 3978:          if (ctx->nibble == lowNbl) {
  5861 branch  0 never executed
  5862 branch  1 never executed
  5863     #####: 3979:            read4bPackedBool;
  5864     #####: 3980:            bo = allocSBool((*ctx->boolAddr) & 0x10);
  5865 call    0 never executed
  5866         -: 3981:          }
  5867         -: 3982:          else {
  5868         -: 3983:            // high nibble
  5869     #####: 3984:            readTypeInHighNbl;
  5870 branch  0 never executed
  5871 branch  1 never executed
  5872     #####: 3985:            read8bPackedBool;
  5873     #####: 3986:            bo = allocSBool((*ctx->boolAddr) & 0x1);
  5874 call    0 never executed
  5875         -: 3987:          }
  5876         -: 3988:        }
  5877         -: 3989:        else {
  5878         -: 3990:          // there was a bool before this one, read bits in nibbles
  5879     #####: 3991:          if (ctx->nibble == lowNbl) {
  5880 branch  0 never executed
  5881 branch  1 never executed
  5882     #####: 3992:            if (ctx->boolShift == 8) {
  5883 branch  0 never executed
  5884 branch  1 never executed
  5885     #####: 3993:              read4bPackedBool;
  5886     #####: 3994:              bo = allocSBool((*ctx->boolAddr) & 0x10);
  5887 call    0 never executed
  5888         -: 3995:            }
  5889         -: 3996:            else {
  5890     #####: 3997:              readTypeOnly;
  5891     #####: 3998:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  5892 call    0 never executed
  5893         -: 3999:            }
  5894         -: 4000:          }
  5895         -: 4001:          else {
  5896         -: 4002:            // high nibble
  5897     #####: 4003:            readTypeInHighNbl;
  5898 branch  0 never executed
  5899 branch  1 never executed
  5900     #####: 4004:            if (ctx->boolShift == 8) {
  5901 branch  0 never executed
  5902 branch  1 never executed
  5903     #####: 4005:              read8bPackedBool;
  5904     #####: 4006:              bo = allocSBool((*ctx->boolAddr) & 0x1);
  5905 call    0 never executed
  5906         -: 4007:            }
  5907         -: 4008:            else {
  5908     #####: 4009:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  5909 call    0 never executed
  5910         -: 4010:            }
  5911         -: 4011:          }
  5912         -: 4012:        }
  5913     #####: 4013:        sArrayPushTiny(array, (smallt *) bo);
  5914 call    0 never executed
  5915     #####: 4014:        break;
  5916         -: 4015:      case S_DICT:
  5917     #####: 4016:        d = NULL;
  5918     #####: 4017:        dictNetDeserialLevel2(&d, data, ctx, /*packed=*/false);
  5919 call    0 never executed
  5920     #####: 4018:        sArrayPushTiny(array, (smallt *) d);
  5921 call    0 never executed
  5922     #####: 4019:        break;
  5923         -: 4020:      case S_DOUBLE:
  5924     #####: 4021:        if (ctx->nibble == lowNbl) {
  5925 branch  0 never executed
  5926 branch  1 never executed
  5927     #####: 4022:          readTypeOnly;
  5928         -: 4023:        }
  5929         -: 4024:        else {
  5930         -: 4025:          // high nibble
  5931     #####: 4026:          readTypeInHighNbl;
  5932 branch  0 never executed
  5933 branch  1 never executed
  5934         -: 4027:        }
  5935     #####: 4028:        D      = (double *)(*data);
  5936     #####: 4029:        *data += sizeof(double);
  5937     #####: 4030:        Do     = allocSDouble(*D);
  5938 call    0 never executed
  5939     #####: 4031:        sArrayPushTiny(array, (smallt *) Do);
  5940 call    0 never executed
  5941     #####: 4032:        break;
  5942         -: 4033:      case S_INT: {
  5943         -: 4034:          u64 v;
  5944     #####: 4035:          if (ctx->nibble == lowNbl) {
  5945 branch  0 never executed
  5946 branch  1 never executed
  5947     #####: 4036:            v = netTypeVarintToUint((u8**)data);
  5948 call    0 never executed
  5949         -: 4037:          }
  5950         -: 4038:          else {
  5951         -: 4039:            // high nibble
  5952     #####: 4040:            readTypeInHighNbl;
  5953 branch  0 never executed
  5954 branch  1 never executed
  5955     #####: 4041:            v = varintToUint(data);
  5956 call    0 never executed
  5957         -: 4042:          }
  5958     #####: 4043:          v  = (v >> 1) ^ (~(v & 1) + 1);
  5959     #####: 4044:          io = allocSInt(v);
  5960 call    0 never executed
  5961     #####: 4045:          sArrayPushTiny(array, (smallt *) io);
  5962 call    0 never executed
  5963         -: 4046:        }
  5964     #####: 4047:        break;
  5965         -: 4048:      case S_STRING:
  5966     #####: 4049:        if (ctx->nibble == lowNbl) {
  5967 branch  0 never executed
  5968 branch  1 never executed
  5969     #####: 4050:          readTypeOnly;
  5970         -: 4051:        }
  5971         -: 4052:        else {
  5972         -: 4053:          // high nibble
  5973     #####: 4054:          readTypeInHighNbl;
  5974 branch  0 never executed
  5975 branch  1 never executed
  5976         -: 4055:        }
  5977     #####: 4056:        s      = (char *)(*data);
  5978     #####: 4057:        *data += strlen(s)+1;
  5979     #####: 4058:        so     = allocSStringTiny(s);
  5980 call    0 never executed
  5981     #####: 4059:        sArrayPushTiny(array, (smallt *) so);
  5982 call    0 never executed
  5983     #####: 4060:        break;
  5984         -: 4061:      case S_ARRAY:
  5985     #####: 4062:        a = NULL;
  5986     #####: 4063:        arrayNetDeserialLevel2(&a, data, ctx, /*packed=*/false);
  5987 call    0 never executed
  5988     #####: 4064:        sArrayPushTiny(array, (smallt *) a);
  5989 call    0 never executed
  5990     #####: 4065:        break;
  5991         -: 4066:      case S_BYTES:
  5992     #####: 4067:        B      = allocSBytes();
  5993 call    0 never executed
  5994     #####: 4068:        if (ctx->nibble == lowNbl) {
  5995 branch  0 never executed
  5996 branch  1 never executed
  5997     #####: 4069:          count  = netTypeVarintToUint((u8**)data);
  5998 call    0 never executed
  5999         -: 4070:        }
  6000         -: 4071:        else {
  6001         -: 4072:          // high nibble
  6002     #####: 4073:          readTypeInHighNbl;
  6003 branch  0 never executed
  6004 branch  1 never executed
  6005     #####: 4074:          count  = varintToUint((u8**)data);
  6006 call    0 never executed
  6007         -: 4075:        }
  6008     #####: 4076:        sBytesPushBuffer(&B, *data, count);
  6009 call    0 never executed
  6010     #####: 4077:        *data += count;
  6011     #####: 4078:        sArrayPushTiny(array, (smallt *) B);
  6012 call    0 never executed
  6013     #####: 4079:        break;
  6014         -: 4080:      case UNIFORM_DICT:
  6015     #####: 4081:        d = NULL;
  6016     #####: 4082:        uniformDictNetDeserialLevel2(&d, data, ctx, /*packed=*/false);
  6017 call    0 never executed
  6018     #####: 4083:        sArrayPushTiny(array, (smallt *) d);
  6019 call    0 never executed
  6020     #####: 4084:        break;
  6021         -: 4085:      case UNIFORM_ARRAY:
  6022     #####: 4086:        a = NULL;
  6023     #####: 4087:        uniformArrayNetDeserialLevel2(&a, data, ctx, /*packed=*/false);
  6024 call    0 never executed
  6025     #####: 4088:        sArrayPushTiny(array, (smallt *) a);
  6026 call    0 never executed
  6027     #####: 4089:        break;
  6028         -: 4090:    }
  6029         -: 4091:  }
  6030         -: 4092:}
  6031         -: 4093:
  6032 function uniformArrayNetDeserialLevel2 called 0 returned 0% blocks executed 0%
  6033     #####: 4094:internal void uniformArrayNetDeserialLevel2(sArrayt **array, u8 **data, contextt *ctx, bool packed) {
  6034     #####: 4095:  sUndefinedt *u = NULL;
  6035     #####: 4096:  sBoolt *bo = NULL;
  6036     #####: 4097:  double *D = NULL;
  6037     #####: 4098:  sDoublet *Do = NULL;
  6038     #####: 4099:  sDictt *d = NULL;
  6039     #####: 4100:  sIntt *io = NULL;
  6040     #####: 4101:  char *s = NULL;
  6041     #####: 4102:  sStringt *so = NULL;
  6042     #####: 4103:  sArrayt *a = NULL;
  6043     #####: 4104:  sBytest *B = NULL;
  6044         -: 4105:  uint32_t count;
  6045         -: 4106:  uint32_t arrayCount;
  6046         -: 4107:  u8 type;
  6047         -: 4108:
  6048     #####: 4109:  if (packed) {
  6049 branch  0 never executed
  6050 branch  1 never executed
  6051     #####: 4110:    type = (**data) & 0xF;
  6052     #####: 4111:    arrayCount = netTypeVarintToUint(data);
  6053 call    0 never executed
  6054         -: 4112:  }
  6055         -: 4113:  else {
  6056     #####: 4114:    if (ctx->nibble == lowNbl) {
  6057 branch  0 never executed
  6058 branch  1 never executed
  6059     #####: 4115:      type = (**data) >> 4;
  6060     #####: 4116:      (*data)++;
  6061     #####: 4117:      arrayCount = varintToUint(data);
  6062 call    0 never executed
  6063         -: 4118:    }
  6064         -: 4119:    else {
  6065     #####: 4120:      readTypeInHighNbl;
  6066 branch  0 never executed
  6067 branch  1 never executed
  6068     #####: 4121:      type = (**data) & 0xF;
  6069     #####: 4122:      arrayCount = netTypeVarintToUint(data);
  6070 call    0 never executed
  6071         -: 4123:    }
  6072         -: 4124:  }
  6073         -: 4125:
  6074     #####: 4126:  if (!arrayCount) {
  6075 branch  0 never executed
  6076 branch  1 never executed
  6077     #####: 4127:    *array = allocSArray();;
  6078 call    0 never executed
  6079     #####: 4128:    ret;
  6080         -: 4129:  }
  6081         -: 4130:
  6082     #####: 4131:  switch(type) {
  6083 branch  0 never executed
  6084 branch  1 never executed
  6085 branch  2 never executed
  6086 branch  3 never executed
  6087 branch  4 never executed
  6088 branch  5 never executed
  6089 branch  6 never executed
  6090 branch  7 never executed
  6091 branch  8 never executed
  6092 branch  9 never executed
  6093 branch 10 never executed
  6094         -: 4132:    case S_UNDEFINED:
  6095     #####: 4133:      loop(arrayCount) {
  6096 branch  0 never executed
  6097 branch  1 never executed
  6098     #####: 4134:        u = allocSUndefined();
  6099 call    0 never executed
  6100     #####: 4135:        sArrayPushTiny(array, (smallt *) u);
  6101 call    0 never executed
  6102         -: 4136:      }
  6103     #####: 4137:      break;
  6104         -: 4138:    case S_BOOL:
  6105     #####: 4139:      loop(arrayCount) {
  6106 branch  0 never executed
  6107 branch  1 never executed
  6108     #####: 4140:        if (!ctx->boolAddr) {
  6109 branch  0 never executed
  6110 branch  1 never executed
  6111     #####: 4141:          read8bPackedBool;
  6112     #####: 4142:          ctx->boolShift = 0;
  6113         -: 4143:        }
  6114     #####: 4144:        if (ctx->boolShift == 8) {
  6115 branch  0 never executed
  6116 branch  1 never executed
  6117     #####: 4145:          read8bPackedBool;
  6118     #####: 4146:          bo = allocSBool((*ctx->boolAddr) & 0x1);
  6119 call    0 never executed
  6120         -: 4147:        }
  6121         -: 4148:        else {
  6122     #####: 4149:          bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  6123 call    0 never executed
  6124         -: 4150:        }
  6125     #####: 4151:        sArrayPushTiny(array, (smallt *) bo);
  6126 call    0 never executed
  6127         -: 4152:      }
  6128     #####: 4153:      break;
  6129         -: 4154:    case S_DICT:
  6130     #####: 4155:      loop(arrayCount) {
  6131 branch  0 never executed
  6132 branch  1 never executed
  6133     #####: 4156:        d = NULL;
  6134     #####: 4157:        dictNetDeserialLevel2(&d, data, ctx, /*packed=*/true);
  6135 call    0 never executed
  6136     #####: 4158:        sArrayPushTiny(array, (smallt *) d);
  6137 call    0 never executed
  6138         -: 4159:      }
  6139     #####: 4160:      break;
  6140         -: 4161:    case S_DOUBLE:
  6141     #####: 4162:      loop(arrayCount) {
  6142 branch  0 never executed
  6143 branch  1 never executed
  6144     #####: 4163:        D      = (double *)(*data);
  6145     #####: 4164:        *data += sizeof(double);
  6146     #####: 4165:        Do     = allocSDouble(*D);
  6147 call    0 never executed
  6148     #####: 4166:        sArrayPushTiny(array, (smallt *) Do);
  6149 call    0 never executed
  6150         -: 4167:      }
  6151     #####: 4168:      break;
  6152         -: 4169:    case S_INT:
  6153     #####: 4170:      loop(arrayCount) {
  6154 branch  0 never executed
  6155 branch  1 never executed
  6156     #####: 4171:        u64 v = varintToUint(data);
  6157 call    0 never executed
  6158     #####: 4172:        v     = (v >> 1) ^ (~(v & 1) + 1);
  6159     #####: 4173:        io    = allocSInt(v);
  6160 call    0 never executed
  6161     #####: 4174:        sArrayPushTiny(array, (smallt *) io);
  6162 call    0 never executed
  6163         -: 4175:      }
  6164     #####: 4176:      break;
  6165         -: 4177:    case S_STRING:
  6166     #####: 4178:      loop(arrayCount) {
  6167 branch  0 never executed
  6168 branch  1 never executed
  6169     #####: 4179:        s      = (char *)(*data);
  6170     #####: 4180:        *data += strlen(s)+1;
  6171     #####: 4181:        so     = allocSStringTiny(s);
  6172 call    0 never executed
  6173     #####: 4182:        sArrayPushTiny(array, (smallt *) so);
  6174 call    0 never executed
  6175         -: 4183:      }
  6176     #####: 4184:      break;
  6177         -: 4185:    case S_ARRAY:
  6178     #####: 4186:      loop(arrayCount) {
  6179 branch  0 never executed
  6180 branch  1 never executed
  6181     #####: 4187:        a = NULL;
  6182     #####: 4188:        arrayNetDeserialLevel2(&a, data, ctx, /*packed=*/true);
  6183 call    0 never executed
  6184     #####: 4189:        sArrayPushTiny(array, (smallt *) a);
  6185 call    0 never executed
  6186         -: 4190:      }
  6187     #####: 4191:      break;
  6188         -: 4192:    case S_BYTES:
  6189     #####: 4193:      loop(arrayCount) {
  6190 branch  0 never executed
  6191 branch  1 never executed
  6192     #####: 4194:        B      = allocSBytes();
  6193 call    0 never executed
  6194     #####: 4195:        count  = varintToUint((u8**)data);
  6195 call    0 never executed
  6196     #####: 4196:        sBytesPushBuffer(&B, *data, count);
  6197 call    0 never executed
  6198     #####: 4197:        *data += count;
  6199     #####: 4198:        sArrayPushTiny(array, (smallt *) B);
  6200 call    0 never executed
  6201         -: 4199:      }
  6202     #####: 4200:      break;
  6203         -: 4201:    case UNIFORM_DICT:
  6204     #####: 4202:      loop(arrayCount) {
  6205 branch  0 never executed
  6206 branch  1 never executed
  6207     #####: 4203:        d = NULL;
  6208     #####: 4204:        uniformDictNetDeserialLevel2(&d, data, ctx, /*packed=*/true);
  6209 call    0 never executed
  6210     #####: 4205:        sArrayPushTiny(array, (smallt *) d);
  6211 call    0 never executed
  6212         -: 4206:      }
  6213     #####: 4207:      break;
  6214         -: 4208:    case UNIFORM_ARRAY:
  6215     #####: 4209:      loop(arrayCount) {
  6216 branch  0 never executed
  6217 branch  1 never executed
  6218     #####: 4210:        a = NULL;
  6219     #####: 4211:        uniformArrayNetDeserialLevel2(&a, data, ctx, /*packed=*/true);
  6220 call    0 never executed
  6221     #####: 4212:        sArrayPushTiny(array, (smallt *) a);
  6222 call    0 never executed
  6223         -: 4213:      }
  6224     #####: 4214:      break;
  6225         -: 4215:  }
  6226         -: 4216:}
  6227         -: 4217:
  6228 function deserialNetSerialLevel2 called 0 returned 0% blocks executed 0%
  6229     #####: 4218:internal smallJsont* deserialNetSerialLevel2(smallJsont *self, smallBytest *data) {
  6230         -: 4219:
  6231     #####: 4220:  if (!data or !data->B or !data->B->count) {
  6232 branch  0 never executed
  6233 branch  1 never executed
  6234 branch  2 never executed
  6235 branch  3 never executed
  6236 branch  4 never executed
  6237 branch  5 never executed
  6238     #####: 4221:    ret self;
  6239         -: 4222:  }
  6240         -: 4223:
  6241     #####: 4224:  smallt *o = netDeserialLevel2(data->B);
  6242 call    0 never executed
  6243         -: 4225:
  6244     #####: 4226:  if (!o) {
  6245 branch  0 never executed
  6246 branch  1 never executed
  6247     #####: 4227:    ret self;
  6248         -: 4228:  }
  6249         -: 4229:
  6250     #####: 4230:  freeG(self);
  6251 call    0 never executed
  6252         -: 4231:
  6253     #####: 4232:  setsoG(self, o);
  6254 call    0 never executed
  6255         -: 4233:
  6256     #####: 4234:  ret self;
  6257         -: 4235:}
  6258         -: 4236:
  6259         -: 4237:// level 3
  6260         -: 4238:// like level 2, elements of identical type in a row are packed
  6261         -: 4239:
  6262         -: 4240:/**
  6263         -: 4241: * deserializer top function
  6264         -: 4242: */
  6265 function netDeserial called 86 returned 100% blocks executed 85%
  6266        86: 4243:internal smallt* netDeserial(sBytest *obj) {
  6267        86: 4244:  smallt   *r = NULL;
  6268        86: 4245:  double   *D = NULL;
  6269        86: 4246:  char     *s = NULL;
  6270        86: 4247:  sBytest  *B = NULL;
  6271         -: 4248:  uint32_t count;
  6272        86: 4249:  char     *data  = NULL;
  6273        86: 4250:  contextt ctx = {.nibble=lowNbl, .nblAddr=NULL, .boolShift = 0, .boolAddr=NULL};
  6274         -: 4251:
  6275        86: 4252:  switch(obj->data & 0xF) {
  6276 branch  0 taken 1%
  6277 branch  1 taken 1%
  6278 branch  2 taken 30%
  6279 branch  3 taken 1%
  6280 branch  4 taken 3%
  6281 branch  5 taken 1%
  6282 branch  6 taken 30%
  6283 branch  7 taken 0%
  6284 branch  8 taken 16%
  6285 branch  9 taken 15%
  6286 branch 10 taken 0%
  6287         -: 4253:    case S_UNDEFINED:
  6288         1: 4254:      r = (smallt *) allocSUndefined();
  6289 call    0 returned 100%
  6290         1: 4255:      break;
  6291         -: 4256:    case S_BOOL:
  6292         1: 4257:      r = (smallt *) allocSBool(obj->data & 0x10);
  6293 call    0 returned 100%
  6294         1: 4258:      break;
  6295         -: 4259:    case S_DICT:
  6296        26: 4260:      data     = (char *)&(obj->data);
  6297         -: 4261:      //debug - ctx.dbuf = (u8*) data;
  6298        26: 4262:      dictNetDeserial((sDictt **)&r, (u8**)&data, &ctx, /*packed=*/false);
  6299 call    0 returned 100%
  6300        26: 4263:      break;
  6301         -: 4264:    case S_DOUBLE:
  6302         1: 4265:      data = &(obj->data)+1;
  6303         1: 4266:      D = (double *)data;
  6304         1: 4267:      r = (smallt *) allocSDouble(*D);
  6305 call    0 returned 100%
  6306         1: 4268:      break;
  6307         -: 4269:    case S_INT:
  6308         3: 4270:      data  = &(obj->data);
  6309         3: 4271:      u64 v = netTypeVarintToUint((u8**)&data);
  6310 call    0 returned 100%
  6311         3: 4272:      v = (v >> 1) ^ (~(v & 1) + 1);
  6312         3: 4273:      r = (smallt *) allocSInt(v);
  6313 call    0 returned 100%
  6314         3: 4274:      break;
  6315         -: 4275:    case S_STRING:
  6316         1: 4276:      s = (char *)&(obj->data)+1;
  6317         1: 4277:      r = (smallt *) allocSStringTiny(s);
  6318 call    0 returned 100%
  6319         1: 4278:      break;
  6320         -: 4279:    case S_ARRAY:
  6321        26: 4280:      data = (char *)&(obj->data);
  6322         -: 4281:      //debug - ctx.dbuf = (u8*) data;
  6323        26: 4282:      arrayNetDeserial((sArrayt **)&r, (u8**)&data, &ctx, /*packed=*/false);
  6324 call    0 returned 100%
  6325        26: 4283:      break;
  6326         -: 4284:    case S_BYTES:
  6327     #####: 4285:      B     = allocSBytes();
  6328 call    0 never executed
  6329     #####: 4286:      data  = &(obj->data);
  6330     #####: 4287:      count = netTypeVarintToUint((u8**)&data);
  6331 call    0 never executed
  6332     #####: 4288:      sBytesPushBuffer(&B, data, count);
  6333 call    0 never executed
  6334     #####: 4289:      r = (smallt *)B;
  6335     #####: 4290:      break;
  6336         -: 4291:    case UNIFORM_DICT:
  6337        14: 4292:      data     = (char *)&(obj->data);
  6338         -: 4293:      //debug - ctx.dbuf = (u8*) data;
  6339        14: 4294:      uniformDictNetDeserial((sDictt **)&r, (u8**)&data, &ctx, /*packed=*/false);
  6340 call    0 returned 100%
  6341        14: 4295:      break;
  6342         -: 4296:    case UNIFORM_ARRAY:
  6343        13: 4297:      data     = (char *)&(obj->data);
  6344         -: 4298:      //debug - ctx.dbuf = (u8*) data;
  6345        13: 4299:      uniformArrayNetDeserial((sArrayt **)&r, (u8**)&data, &ctx, /*packed=*/false);
  6346 call    0 returned 100%
  6347        13: 4300:      break;
  6348         -: 4301:  }
  6349         -: 4302:
  6350        86: 4303:  ret r;
  6351         -: 4304:}
  6352         -: 4305:
  6353         -: 4306:/**
  6354         -: 4307: * deserialize dictionary from data
  6355         -: 4308: *
  6356         -: 4309: * a new dictionary is allocated
  6357         -: 4310: *
  6358         -: 4311: * \param
  6359         -: 4312: *    dict dictionary holding the elements
  6360         -: 4313: *    data serialized dictionary
  6361         -: 4314: */
  6362 function dictNetDeserial called 56 returned 100% blocks executed 84%
  6363        56: 4315:internal void dictNetDeserial(sDictt **dict, u8 **data, contextt *ctx, bool packed) {
  6364        56: 4316:  sUndefinedt *u = NULL;
  6365        56: 4317:  sBoolt *bo = NULL;
  6366        56: 4318:  double *D = NULL;
  6367        56: 4319:  sDoublet *Do = NULL;
  6368        56: 4320:  sDictt *d = NULL;
  6369        56: 4321:  sIntt *io = NULL;
  6370        56: 4322:  char *s = NULL;
  6371        56: 4323:  sStringt *so = NULL;
  6372        56: 4324:  sArrayt *a = NULL;
  6373        56: 4325:  sBytest *B = NULL;
  6374         -: 4326:  uint32_t count;
  6375         -: 4327:  uint32_t dictCount;
  6376         -: 4328:
  6377        56: 4329:  if (packed) {
  6378 branch  0 taken 48% (fallthrough)
  6379 branch  1 taken 52%
  6380        27: 4330:    dictCount = varintToUint(data);
  6381 call    0 returned 100%
  6382         -: 4331:  }
  6383         -: 4332:  else {
  6384        29: 4333:    if (ctx->nibble == lowNbl) {
  6385 branch  0 taken 93% (fallthrough)
  6386 branch  1 taken 7%
  6387        27: 4334:      dictCount = netTypeVarintToUint(data);
  6388 call    0 returned 100%
  6389         -: 4335:    }
  6390         -: 4336:    else {
  6391         -: 4337:      // high nibble
  6392         -: 4338:      // type = *(ctx->dbuf + ctx->nblOffset) >> 4;
  6393         -: 4339:      #define readTypeInHighNbl\
  6394         -: 4340:      ctx->nibble  = lowNbl;\
  6395         -: 4341:      if (ctx->nblAddr == *data)\
  6396         -: 4342:      /* data points to the type, next byte is count */\
  6397         -: 4343:      (*data)++
  6398         2: 4344:      readTypeInHighNbl;
  6399 branch  0 taken 0% (fallthrough)
  6400 branch  1 taken 100%
  6401         2: 4345:      dictCount = varintToUint(data);
  6402 call    0 returned 100%
  6403         -: 4346:    }
  6404         -: 4347:  }
  6405         -: 4348:
  6406        56: 4349:  if (!dictCount) {
  6407 branch  0 taken 18% (fallthrough)
  6408 branch  1 taken 82%
  6409        10: 4350:    *dict = allocSDict();
  6410 call    0 returned 100%
  6411        66: 4351:    ret;
  6412         -: 4352:  }
  6413         -: 4353:
  6414        46: 4354:  bool inPack = false;
  6415         -: 4355:  u8 packedType;
  6416         -: 4356:  size_t packCount;
  6417       209: 4357:  loop(dictCount) {
  6418 branch  0 taken 78%
  6419 branch  1 taken 22% (fallthrough)
  6420       163: 4358:    char *key  = (char*)*data;
  6421       163: 4359:    *data     += strlen(key)+1;
  6422         -: 4360:    char type;
  6423       163: 4361:    if (inPack) {
  6424 branch  0 taken 23% (fallthrough)
  6425 branch  1 taken 77%
  6426        38: 4362:      type = packedType;
  6427         -: 4363:    }
  6428         -: 4364:    else {
  6429       125: 4365:      if (ctx->nibble == lowNbl) {
  6430 branch  0 taken 66% (fallthrough)
  6431 branch  1 taken 34%
  6432        83: 4366:        type = (**data) & 0xF;
  6433         -: 4367:      }
  6434         -: 4368:      else {
  6435         -: 4369:        // high nibble
  6436        42: 4370:        type = (*ctx->nblAddr) >> 4;
  6437         -: 4371:      }
  6438         -: 4372:    }
  6439         -: 4373:
  6440       163: 4374:    switch(type) {
  6441 branch  0 taken 18%
  6442 branch  1 taken 19%
  6443 branch  2 taken 1%
  6444 branch  3 taken 1%
  6445 branch  4 taken 15%
  6446 branch  5 taken 9%
  6447 branch  6 taken 2%
  6448 branch  7 taken 1%
  6449 branch  8 taken 9%
  6450 branch  9 taken 6%
  6451 branch 10 taken 5%
  6452 branch 11 taken 5%
  6453 branch 12 taken 5%
  6454 branch 13 taken 0%
  6455 branch 14 taken 2%
  6456 branch 15 taken 2%
  6457 branch 16 taken 0%
  6458         -: 4375:      case S_UNDEFINED:
  6459        29: 4376:        if (ctx->nibble == lowNbl) {
  6460 branch  0 taken 93% (fallthrough)
  6461 branch  1 taken 7%
  6462         -: 4377:          #define readTypeOnly\
  6463         -: 4378:          ctx->nibble  = highNbl;\
  6464         -: 4379:          ctx->nblAddr = *data;\
  6465         -: 4380:          (*data)++
  6466        27: 4381:          readTypeOnly;
  6467         -: 4382:        }
  6468         -: 4383:        else {
  6469         -: 4384:          // high nibble
  6470         2: 4385:          readTypeInHighNbl;
  6471 branch  0 taken 0% (fallthrough)
  6472 branch  1 taken 100%
  6473         -: 4386:        }
  6474        29: 4387:        u = allocSUndefined();
  6475 call    0 returned 100%
  6476        29: 4388:        sDictPushTiny(dict, key, (smallt *) u);
  6477 call    0 returned 100%
  6478        29: 4389:        break;
  6479         -: 4390:      case S_BOOL:
  6480        31: 4391:        if (!ctx->boolAddr) {
  6481 branch  0 taken 16% (fallthrough)
  6482 branch  1 taken 84%
  6483         -: 4392:          // new packed bools
  6484         5: 4393:          if (ctx->nibble == lowNbl) {
  6485 branch  0 taken 60% (fallthrough)
  6486 branch  1 taken 40%
  6487         -: 4394:            #define read4bPackedBool\
  6488         -: 4395:            ctx->boolShift  = 5;\
  6489         -: 4396:            ctx->boolAddr   = *data;\
  6490         -: 4397:            (*data)++
  6491         3: 4398:            read4bPackedBool;
  6492         3: 4399:            bo = allocSBool((*ctx->boolAddr) & 0x10);
  6493 call    0 returned 100%
  6494         -: 4400:          }
  6495         -: 4401:          else {
  6496         -: 4402:            // high nibble
  6497         2: 4403:            readTypeInHighNbl;
  6498 branch  0 taken 0% (fallthrough)
  6499 branch  1 taken 100%
  6500         -: 4404:            #define read8bPackedBool\
  6501         -: 4405:            ctx->boolShift  = 1;\
  6502         -: 4406:            ctx->boolAddr   = *data;\
  6503         -: 4407:            (*data)++
  6504         2: 4408:            read8bPackedBool;
  6505         2: 4409:            bo = allocSBool((*ctx->boolAddr) & 0x1);
  6506 call    0 returned 100%
  6507         -: 4410:          }
  6508         -: 4411:        }
  6509         -: 4412:        else {
  6510         -: 4413:          // there was a bool before this one, read bits in nibbles
  6511        26: 4414:          if (ctx->nibble == lowNbl) {
  6512 branch  0 taken 58% (fallthrough)
  6513 branch  1 taken 42%
  6514        15: 4415:            if (ctx->boolShift == 8) {
  6515 branch  0 taken 7% (fallthrough)
  6516 branch  1 taken 93%
  6517         1: 4416:              read4bPackedBool;
  6518         1: 4417:              bo = allocSBool((*ctx->boolAddr) & 0x10);
  6519 call    0 returned 100%
  6520         -: 4418:            }
  6521         -: 4419:            else {
  6522        14: 4420:              readTypeOnly;
  6523        14: 4421:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  6524 call    0 returned 100%
  6525         -: 4422:            }
  6526         -: 4423:          }
  6527         -: 4424:          else {
  6528         -: 4425:            // high nibble
  6529        11: 4426:            readTypeInHighNbl;
  6530 branch  0 taken 0% (fallthrough)
  6531 branch  1 taken 100%
  6532        11: 4427:            if (ctx->boolShift == 8) {
  6533 branch  0 taken 18% (fallthrough)
  6534 branch  1 taken 82%
  6535         2: 4428:              read8bPackedBool;
  6536         2: 4429:              bo = allocSBool((*ctx->boolAddr) & 0x1);
  6537 call    0 returned 100%
  6538         -: 4430:            }
  6539         -: 4431:            else {
  6540         -: 4432:              // high nibble
  6541         9: 4433:              readTypeInHighNbl;
  6542 branch  0 taken 0% (fallthrough)
  6543 branch  1 taken 100%
  6544         9: 4434:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  6545 call    0 returned 100%
  6546         -: 4435:            }
  6547         -: 4436:          }
  6548         -: 4437:        }
  6549        31: 4438:        sDictPushTiny(dict, key, (smallt *) bo);
  6550 call    0 returned 100%
  6551        31: 4439:        break;
  6552         -: 4440:      case S_DICT:
  6553         1: 4441:        d = NULL;
  6554         1: 4442:        dictNetDeserial(&d, data, ctx, /*packed=*/false);
  6555 call    0 returned 100%
  6556         1: 4443:        sDictPushTiny(dict, key, (smallt *) d);
  6557 call    0 returned 100%
  6558         1: 4444:        break;
  6559         -: 4445:      case S_DOUBLE:
  6560         2: 4446:        if (ctx->nibble == lowNbl) {
  6561 branch  0 taken 50% (fallthrough)
  6562 branch  1 taken 50%
  6563         1: 4447:          readTypeOnly;
  6564         -: 4448:        }
  6565         -: 4449:        else {
  6566         -: 4450:          // high nibble
  6567         1: 4451:          readTypeInHighNbl;
  6568 branch  0 taken 0% (fallthrough)
  6569 branch  1 taken 100%
  6570         -: 4452:        }
  6571         2: 4453:        D      = (double *)(*data);
  6572         2: 4454:        *data += sizeof(double);
  6573         2: 4455:        Do     = allocSDouble(*D);
  6574 call    0 returned 100%
  6575         2: 4456:        sDictPushTiny(dict, key, (smallt *) Do);
  6576 call    0 returned 100%
  6577         2: 4457:        break;
  6578         -: 4458:      case S_INT: {
  6579         -: 4459:          u64 v;
  6580        24: 4460:          if (ctx->nibble == lowNbl) {
  6581 branch  0 taken 50% (fallthrough)
  6582 branch  1 taken 50%
  6583        12: 4461:            v = netTypeVarintToUint((u8**)data);
  6584 call    0 returned 100%
  6585         -: 4462:          }
  6586         -: 4463:          else {
  6587         -: 4464:            // high nibble
  6588        12: 4465:            readTypeInHighNbl;
  6589 branch  0 taken 0% (fallthrough)
  6590 branch  1 taken 100%
  6591        12: 4466:            v = varintToUint(data);
  6592 call    0 returned 100%
  6593         -: 4467:          }
  6594        24: 4468:          v  = (v >> 1) ^ (~(v & 1) + 1);
  6595        24: 4469:          io = allocSInt(v);
  6596 call    0 returned 100%
  6597        24: 4470:          sDictPushTiny(dict, key, (smallt *) io);
  6598 call    0 returned 100%
  6599         -: 4471:        }
  6600        24: 4472:        break;
  6601         -: 4473:      case S_STRING:
  6602        14: 4474:        if (ctx->nibble == lowNbl) {
  6603 branch  0 taken 93% (fallthrough)
  6604 branch  1 taken 7%
  6605        13: 4475:          readTypeOnly;
  6606         -: 4476:        }
  6607         -: 4477:        else {
  6608         -: 4478:          // high nibble
  6609         1: 4479:          readTypeInHighNbl;
  6610 branch  0 taken 0% (fallthrough)
  6611 branch  1 taken 100%
  6612         -: 4480:        }
  6613        14: 4481:        s      = (char *)(*data);
  6614        14: 4482:        *data += strlen(s)+1;
  6615        14: 4483:        so     = allocSStringTiny(s);
  6616 call    0 returned 100%
  6617        14: 4484:        sDictPushTiny(dict, key, (smallt *) so);
  6618 call    0 returned 100%
  6619        14: 4485:        break;
  6620         -: 4486:      case S_ARRAY:
  6621         3: 4487:        a = NULL;
  6622         3: 4488:        arrayNetDeserial(&a, data, ctx, /*packed=*/false);
  6623 call    0 returned 100%
  6624         3: 4489:        sDictPushTiny(dict, key, (smallt *) a);
  6625 call    0 returned 100%
  6626         3: 4490:        break;
  6627         -: 4491:      case S_BYTES:
  6628         2: 4492:        B      = allocSBytes();
  6629 call    0 returned 100%
  6630         2: 4493:        if (ctx->nibble == lowNbl) {
  6631 branch  0 taken 50% (fallthrough)
  6632 branch  1 taken 50%
  6633         1: 4494:          count  = netTypeVarintToUint((u8**)data);
  6634 call    0 returned 100%
  6635         -: 4495:        }
  6636         -: 4496:        else {
  6637         -: 4497:          // high nibble
  6638         1: 4498:          readTypeInHighNbl;
  6639 branch  0 taken 0% (fallthrough)
  6640 branch  1 taken 100%
  6641         1: 4499:          count  = varintToUint((u8**)data);
  6642 call    0 returned 100%
  6643         -: 4500:        }
  6644         2: 4501:        sBytesPushBuffer(&B, *data, count);
  6645 call    0 returned 100%
  6646         2: 4502:        *data += count;
  6647         2: 4503:        sDictPushTiny(dict, key, (smallt *) B);
  6648 call    0 returned 100%
  6649         2: 4504:        break;
  6650         -: 4505:      case PK_DICT:
  6651        15: 4506:        if (!inPack) {
  6652 branch  0 taken 20% (fallthrough)
  6653 branch  1 taken 80%
  6654         3: 4507:          inPack = true;
  6655         3: 4508:          if (ctx->nibble == lowNbl) {
  6656 branch  0 taken 67% (fallthrough)
  6657 branch  1 taken 33%
  6658         2: 4509:            packCount  = netTypeVarintToUint((u8**)data);
  6659 call    0 returned 100%
  6660         -: 4510:          }
  6661         -: 4511:          else {
  6662         -: 4512:            // high nibble
  6663         1: 4513:            readTypeInHighNbl;
  6664 branch  0 taken 0% (fallthrough)
  6665 branch  1 taken 100%
  6666         1: 4514:            packCount  = varintToUint((u8**)data);
  6667 call    0 returned 100%
  6668         -: 4515:          }
  6669         3: 4516:          packedType = PK_DICT;
  6670         -: 4517:        }
  6671         -: 4518:
  6672        15: 4519:        d = NULL;
  6673        15: 4520:        dictNetDeserial(&d, data, ctx, /*packed=*/true);
  6674 call    0 returned 100%
  6675        15: 4521:        sDictPushTiny(dict, key, (smallt *) d);
  6676 call    0 returned 100%
  6677         -: 4522:        // stop unpacking when packCount == 0
  6678        15: 4523:        packCount--;
  6679        15: 4524:        if (!packCount) inPack = false;
  6680 branch  0 taken 20% (fallthrough)
  6681 branch  1 taken 80%
  6682        15: 4525:        break;
  6683         -: 4526:      case PK_DOUBLE:
  6684        10: 4527:        if (!inPack) {
  6685 branch  0 taken 20% (fallthrough)
  6686 branch  1 taken 80%
  6687         2: 4528:          inPack = true;
  6688         2: 4529:          if (ctx->nibble == lowNbl) {
  6689 branch  0 taken 50% (fallthrough)
  6690 branch  1 taken 50%
  6691         1: 4530:            packCount  = netTypeVarintToUint((u8**)data);
  6692 call    0 returned 100%
  6693         -: 4531:          }
  6694         -: 4532:          else {
  6695         -: 4533:            // high nibble
  6696         1: 4534:            readTypeInHighNbl;
  6697 branch  0 taken 0% (fallthrough)
  6698 branch  1 taken 100%
  6699         1: 4535:            packCount  = varintToUint((u8**)data);
  6700 call    0 returned 100%
  6701         -: 4536:          }
  6702         2: 4537:          packedType = PK_DOUBLE;
  6703         -: 4538:        }
  6704         -: 4539:
  6705        10: 4540:        D      = (double *)(*data);
  6706        10: 4541:        *data += sizeof(double);
  6707        10: 4542:        Do     = allocSDouble(*D);
  6708 call    0 returned 100%
  6709        10: 4543:        sDictPushTiny(dict, key, (smallt *) Do);
  6710 call    0 returned 100%
  6711         -: 4544:        // stop unpacking when packCount == 0
  6712        10: 4545:        packCount--;
  6713        10: 4546:        if (!packCount) inPack = false;
  6714 branch  0 taken 20% (fallthrough)
  6715 branch  1 taken 80%
  6716        10: 4547:        break;
  6717         -: 4548:      case PK_INT:
  6718         8: 4549:        if (!inPack) {
  6719 branch  0 taken 25% (fallthrough)
  6720 branch  1 taken 75%
  6721         2: 4550:          inPack = true;
  6722         2: 4551:          if (ctx->nibble == lowNbl) {
  6723 branch  0 taken 50% (fallthrough)
  6724 branch  1 taken 50%
  6725         1: 4552:            packCount  = netTypeVarintToUint((u8**)data);
  6726 call    0 returned 100%
  6727         -: 4553:          }
  6728         -: 4554:          else {
  6729         -: 4555:            // high nibble
  6730         1: 4556:            readTypeInHighNbl;
  6731 branch  0 taken 0% (fallthrough)
  6732 branch  1 taken 100%
  6733         1: 4557:            packCount  = varintToUint((u8**)data);
  6734 call    0 returned 100%
  6735         -: 4558:          }
  6736         2: 4559:          packedType = PK_INT;
  6737         -: 4560:        }
  6738         -: 4561:
  6739         8: 4562:        u64 v = varintToUint(data);
  6740 call    0 returned 100%
  6741         8: 4563:        v     = (v >> 1) ^ (~(v & 1) + 1);
  6742         8: 4564:        io    = allocSInt(v);
  6743 call    0 returned 100%
  6744         8: 4565:        sDictPushTiny(dict, key, (smallt *) io);
  6745 call    0 returned 100%
  6746         -: 4566:        // stop unpacking when packCount == 0
  6747         8: 4567:        packCount--;
  6748         8: 4568:        if (!packCount) inPack = false;
  6749 branch  0 taken 25% (fallthrough)
  6750 branch  1 taken 75%
  6751         8: 4569:        break;
  6752         -: 4570:      case PK_STRING:
  6753         8: 4571:        if (!inPack) {
  6754 branch  0 taken 25% (fallthrough)
  6755 branch  1 taken 75%
  6756         2: 4572:          inPack = true;
  6757         2: 4573:          if (ctx->nibble == lowNbl) {
  6758 branch  0 taken 50% (fallthrough)
  6759 branch  1 taken 50%
  6760         1: 4574:            packCount  = netTypeVarintToUint((u8**)data);
  6761 call    0 returned 100%
  6762         -: 4575:          }
  6763         -: 4576:          else {
  6764         -: 4577:            // high nibble
  6765         1: 4578:            readTypeInHighNbl;
  6766 branch  0 taken 0% (fallthrough)
  6767 branch  1 taken 100%
  6768         1: 4579:            packCount  = varintToUint((u8**)data);
  6769 call    0 returned 100%
  6770         -: 4580:          }
  6771         2: 4581:          packedType = PK_STRING;
  6772         -: 4582:        }
  6773         -: 4583:
  6774         8: 4584:        s          = (char *)(*data);
  6775         8: 4585:        *data     += strlen(s)+1;
  6776         8: 4586:        so         = allocSStringTiny(s);
  6777 call    0 returned 100%
  6778         8: 4587:        sDictPushTiny(dict, key, (smallt *) so);
  6779 call    0 returned 100%
  6780         -: 4588:        // stop unpacking when packCount == 0
  6781         8: 4589:        packCount--;
  6782         8: 4590:        if (!packCount) inPack = false;
  6783 branch  0 taken 25% (fallthrough)
  6784 branch  1 taken 75%
  6785         8: 4591:        break;
  6786         -: 4592:      case PK_ARRAY:
  6787         8: 4593:        if (!inPack) {
  6788 branch  0 taken 25% (fallthrough)
  6789 branch  1 taken 75%
  6790         2: 4594:          inPack = true;
  6791         2: 4595:          if (ctx->nibble == lowNbl) {
  6792 branch  0 taken 50% (fallthrough)
  6793 branch  1 taken 50%
  6794         1: 4596:            packCount  = netTypeVarintToUint((u8**)data);
  6795 call    0 returned 100%
  6796         -: 4597:          }
  6797         -: 4598:          else {
  6798         -: 4599:            // high nibble
  6799         1: 4600:            readTypeInHighNbl;
  6800 branch  0 taken 0% (fallthrough)
  6801 branch  1 taken 100%
  6802         1: 4601:            packCount  = varintToUint((u8**)data);
  6803 call    0 returned 100%
  6804         -: 4602:          }
  6805         2: 4603:          packedType = PK_ARRAY;
  6806         -: 4604:        }
  6807         -: 4605:
  6808         8: 4606:        a          = NULL;
  6809         8: 4607:        arrayNetDeserial(&a, data, ctx, /*packed=*/true);
  6810 call    0 returned 100%
  6811         8: 4608:        sDictPushTiny(dict, key, (smallt *) a);
  6812 call    0 returned 100%
  6813         -: 4609:        // stop unpacking when packCount == 0
  6814         8: 4610:        packCount--;
  6815         8: 4611:        if (!packCount) inPack = false;
  6816 branch  0 taken 25% (fallthrough)
  6817 branch  1 taken 75%
  6818         8: 4612:        break;
  6819         -: 4613:      case PK_BYTES:
  6820     #####: 4614:        if (!inPack) {
  6821 branch  0 never executed
  6822 branch  1 never executed
  6823     #####: 4615:          inPack = true;
  6824     #####: 4616:          if (ctx->nibble == lowNbl) {
  6825 branch  0 never executed
  6826 branch  1 never executed
  6827     #####: 4617:            packCount  = netTypeVarintToUint((u8**)data);
  6828 call    0 never executed
  6829         -: 4618:          }
  6830         -: 4619:          else {
  6831         -: 4620:            // high nibble
  6832     #####: 4621:            readTypeInHighNbl;
  6833 branch  0 never executed
  6834 branch  1 never executed
  6835     #####: 4622:            packCount  = varintToUint((u8**)data);
  6836 call    0 never executed
  6837         -: 4623:          }
  6838     #####: 4624:          packedType = PK_BYTES;
  6839         -: 4625:        }
  6840         -: 4626:
  6841     #####: 4627:        B          = allocSBytes();
  6842 call    0 never executed
  6843     #####: 4628:        count      = varintToUint((u8**)data);
  6844 call    0 never executed
  6845     #####: 4629:        sBytesPushBuffer(&B, *data, count);
  6846 call    0 never executed
  6847     #####: 4630:        *data     += count;
  6848     #####: 4631:        sDictPushTiny(dict, key, (smallt *) B);
  6849 call    0 never executed
  6850         -: 4632:        // stop unpacking when packCount == 0
  6851     #####: 4633:        packCount--;
  6852     #####: 4634:        if (!packCount) inPack = false;
  6853 branch  0 never executed
  6854 branch  1 never executed
  6855     #####: 4635:        break;
  6856         -: 4636:      case UNIFORM_DICT:
  6857         4: 4637:        d = NULL;
  6858         4: 4638:        uniformDictNetDeserial(&d, data, ctx, /*packed=*/false);
  6859 call    0 returned 100%
  6860         4: 4639:        sDictPushTiny(dict, key, (smallt *) d);
  6861 call    0 returned 100%
  6862         4: 4640:        break;
  6863         -: 4641:      case UNIFORM_ARRAY:
  6864         4: 4642:        a = NULL;
  6865         4: 4643:        uniformArrayNetDeserial(&a, data, ctx, /*packed=*/false);
  6866 call    0 returned 100%
  6867         4: 4644:        sDictPushTiny(dict, key, (smallt *) a);
  6868 call    0 returned 100%
  6869         4: 4645:        break;
  6870         -: 4646:    }
  6871         -: 4647:  }
  6872         -: 4648:}
  6873         -: 4649:
  6874         -: 4650:/**
  6875         -: 4651: * deserialize dictionary from data
  6876         -: 4652: *
  6877         -: 4653: * a new dictionary is allocated
  6878         -: 4654: *
  6879         -: 4655: * \param
  6880         -: 4656: *    dict dictionary holding the elements
  6881         -: 4657: *    data serialized dictionary
  6882         -: 4658: */
  6883 function uniformDictNetDeserial called 27 returned 100% blocks executed 97%
  6884        27: 4659:internal void uniformDictNetDeserial(sDictt **dict, u8 **data, contextt *ctx, bool packed) {
  6885        27: 4660:  sUndefinedt *u = NULL;
  6886        27: 4661:  sBoolt *bo = NULL;
  6887        27: 4662:  double *D = NULL;
  6888        27: 4663:  sDoublet *Do = NULL;
  6889        27: 4664:  sDictt *d = NULL;
  6890        27: 4665:  sIntt *io = NULL;
  6891        27: 4666:  char *s = NULL;
  6892        27: 4667:  sStringt *so = NULL;
  6893        27: 4668:  sArrayt *a = NULL;
  6894        27: 4669:  sBytest *B = NULL;
  6895         -: 4670:  uint32_t count;
  6896         -: 4671:  uint32_t dictCount;
  6897         -: 4672:  u8 type;
  6898         -: 4673:
  6899        27: 4674:  if (packed) {
  6900 branch  0 taken 15% (fallthrough)
  6901 branch  1 taken 85%
  6902         4: 4675:    type = (**data) & 0xF;
  6903         4: 4676:    dictCount = netTypeVarintToUint(data);
  6904 call    0 returned 100%
  6905         -: 4677:  }
  6906         -: 4678:  else {
  6907        23: 4679:    if (ctx->nibble == lowNbl) {
  6908 branch  0 taken 91% (fallthrough)
  6909 branch  1 taken 9%
  6910        21: 4680:      type = (**data) >> 4;
  6911        21: 4681:      (*data)++;
  6912        21: 4682:      dictCount = varintToUint(data);
  6913 call    0 returned 100%
  6914         -: 4683:    }
  6915         -: 4684:    else {
  6916         2: 4685:      readTypeInHighNbl;
  6917 branch  0 taken 0% (fallthrough)
  6918 branch  1 taken 100%
  6919         2: 4686:      type = (**data) & 0xF;
  6920         2: 4687:      dictCount = netTypeVarintToUint(data);
  6921 call    0 returned 100%
  6922         -: 4688:    }
  6923         -: 4689:  }
  6924         -: 4690:
  6925        27: 4691:  if (!dictCount) {
  6926 branch  0 taken 7% (fallthrough)
  6927 branch  1 taken 93%
  6928         2: 4692:    *dict = allocSDict();
  6929 call    0 returned 100%
  6930        29: 4693:    ret;
  6931         -: 4694:  }
  6932         -: 4695:
  6933         -: 4696:
  6934        25: 4697:  switch(type) {
  6935 branch  0 taken 4%
  6936 branch  1 taken 16%
  6937 branch  2 taken 4%
  6938 branch  3 taken 4%
  6939 branch  4 taken 36%
  6940 branch  5 taken 20%
  6941 branch  6 taken 4%
  6942 branch  7 taken 4%
  6943 branch  8 taken 4%
  6944 branch  9 taken 4%
  6945 branch 10 taken 0%
  6946         -: 4698:    case S_UNDEFINED:
  6947         7: 4699:      loop(dictCount) {
  6948 branch  0 taken 86%
  6949 branch  1 taken 14% (fallthrough)
  6950         6: 4700:        char *key  = (char*)*data;
  6951         6: 4701:        *data     += strlen(key)+1;
  6952         6: 4702:        u = allocSUndefined();
  6953 call    0 returned 100%
  6954         6: 4703:        sDictPushTiny(dict, key, (smallt *) u);
  6955 call    0 returned 100%
  6956         -: 4704:      }
  6957         1: 4705:      break;
  6958         -: 4706:    case S_BOOL:
  6959        19: 4707:      loop(dictCount) {
  6960 branch  0 taken 79%
  6961 branch  1 taken 21% (fallthrough)
  6962        15: 4708:        char *key  = (char*)*data;
  6963        15: 4709:        *data     += strlen(key)+1;
  6964        15: 4710:        if (!ctx->boolAddr) {
  6965 branch  0 taken 20% (fallthrough)
  6966 branch  1 taken 80%
  6967         3: 4711:          read8bPackedBool;
  6968         3: 4712:          ctx->boolShift = 0;
  6969         -: 4713:        }
  6970        15: 4714:        if (ctx->boolShift == 8) {
  6971 branch  0 taken 7% (fallthrough)
  6972 branch  1 taken 93%
  6973         1: 4715:          readTypeInHighNbl;
  6974 branch  0 taken 0% (fallthrough)
  6975 branch  1 taken 100%
  6976         1: 4716:          read8bPackedBool;
  6977         1: 4717:          bo = allocSBool((*ctx->boolAddr) & 0x1);
  6978 call    0 returned 100%
  6979         -: 4718:        }
  6980         -: 4719:        else {
  6981         -: 4720:          // high nibble
  6982        14: 4721:          readTypeInHighNbl;
  6983 branch  0 taken 0% (fallthrough)
  6984 branch  1 taken 100%
  6985        14: 4722:          bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  6986 call    0 returned 100%
  6987         -: 4723:        }
  6988        15: 4724:        sDictPushTiny(dict, key, (smallt *) bo);
  6989 call    0 returned 100%
  6990         -: 4725:      }
  6991         4: 4726:      break;
  6992         -: 4727:    case S_DICT:
  6993         3: 4728:      loop(dictCount) {
  6994 branch  0 taken 67%
  6995 branch  1 taken 33% (fallthrough)
  6996         2: 4729:        char *key  = (char*)*data;
  6997         2: 4730:        *data     += strlen(key)+1;
  6998         2: 4731:        d          = NULL;
  6999         2: 4732:        dictNetDeserial(&d, data, ctx, /*packed=*/true);
  7000 call    0 returned 100%
  7001         2: 4733:        sDictPushTiny(dict, key, (smallt *) d);
  7002 call    0 returned 100%
  7003         -: 4734:      }
  7004         1: 4735:      break;
  7005         -: 4736:    case S_DOUBLE:
  7006         4: 4737:      loop(dictCount) {
  7007 branch  0 taken 75%
  7008 branch  1 taken 25% (fallthrough)
  7009         3: 4738:        char *key  = (char*)*data;
  7010         3: 4739:        *data     += strlen(key)+1;
  7011         3: 4740:        D          = (double *)(*data);
  7012         3: 4741:        *data     += sizeof(double);
  7013         3: 4742:        Do         = allocSDouble(*D);
  7014 call    0 returned 100%
  7015         3: 4743:        sDictPushTiny(dict, key, (smallt *) Do);
  7016 call    0 returned 100%
  7017         -: 4744:      }
  7018         1: 4745:      break;
  7019         -: 4746:    case S_INT:
  7020        21: 4747:      loop(dictCount) {
  7021 branch  0 taken 57%
  7022 branch  1 taken 43% (fallthrough)
  7023        12: 4748:        char *key  = (char*)*data;
  7024        12: 4749:        *data     += strlen(key)+1;
  7025        12: 4750:        u64 v      = varintToUint(data);
  7026 call    0 returned 100%
  7027        12: 4751:        v          = (v >> 1) ^ (~(v & 1) + 1);
  7028        12: 4752:        io         = allocSInt(v);
  7029 call    0 returned 100%
  7030        12: 4753:        sDictPushTiny(dict, key, (smallt *) io);
  7031 call    0 returned 100%
  7032         -: 4754:      }
  7033         9: 4755:      break;
  7034         -: 4756:    case S_STRING:
  7035        16: 4757:      loop(dictCount) {
  7036 branch  0 taken 69%
  7037 branch  1 taken 31% (fallthrough)
  7038        11: 4758:        char *key  = (char*)*data;
  7039        11: 4759:        *data     += strlen(key)+1;
  7040        11: 4760:        s          = (char *)(*data);
  7041        11: 4761:        *data     += strlen(s)+1;
  7042        11: 4762:        so         = allocSStringTiny(s);
  7043 call    0 returned 100%
  7044        11: 4763:        sDictPushTiny(dict, key, (smallt *) so);
  7045 call    0 returned 100%
  7046         -: 4764:      }
  7047         5: 4765:      break;
  7048         -: 4766:    case S_ARRAY:
  7049         2: 4767:      loop(dictCount) {
  7050 branch  0 taken 50%
  7051 branch  1 taken 50% (fallthrough)
  7052         1: 4768:        char *key  = (char*)*data;
  7053         1: 4769:        *data     += strlen(key)+1;
  7054         1: 4770:        a          = NULL;
  7055         1: 4771:        arrayNetDeserial(&a, data, ctx, /*packed=*/true);
  7056 call    0 returned 100%
  7057         1: 4772:        sDictPushTiny(dict, key, (smallt *) a);
  7058 call    0 returned 100%
  7059         -: 4773:      }
  7060         1: 4774:      break;
  7061         -: 4775:    case S_BYTES:
  7062         3: 4776:      loop(dictCount) {
  7063 branch  0 taken 67%
  7064 branch  1 taken 33% (fallthrough)
  7065         2: 4777:        char *key  = (char*)*data;
  7066         2: 4778:        *data     += strlen(key)+1;
  7067         2: 4779:        B          = allocSBytes();
  7068 call    0 returned 100%
  7069         2: 4780:        count      = varintToUint((u8**)data);
  7070 call    0 returned 100%
  7071         2: 4781:        sBytesPushBuffer(&B, *data, count);
  7072 call    0 returned 100%
  7073         2: 4782:        *data     += count;
  7074         2: 4783:        sDictPushTiny(dict, key, (smallt *) B);
  7075 call    0 returned 100%
  7076         -: 4784:      }
  7077         1: 4785:      break;
  7078         -: 4786:    case UNIFORM_DICT:
  7079         3: 4787:      loop(dictCount) {
  7080 branch  0 taken 67%
  7081 branch  1 taken 33% (fallthrough)
  7082         2: 4788:        char *key  = (char*)*data;
  7083         2: 4789:        *data     += strlen(key)+1;
  7084         2: 4790:        d          = NULL;
  7085         2: 4791:        uniformDictNetDeserial(&d, data, ctx, /*packed=*/true);
  7086 call    0 returned 100%
  7087         2: 4792:        sDictPushTiny(dict, key, (smallt *) d);
  7088 call    0 returned 100%
  7089         -: 4793:      }
  7090         1: 4794:      break;
  7091         -: 4795:    case UNIFORM_ARRAY:
  7092         2: 4796:      loop(dictCount) {
  7093 branch  0 taken 50%
  7094 branch  1 taken 50% (fallthrough)
  7095         1: 4797:        char *key  = (char*)*data;
  7096         1: 4798:        *data     += strlen(key)+1;
  7097         1: 4799:        a          = NULL;
  7098         1: 4800:        uniformArrayNetDeserial(&a, data, ctx, /*packed=*/true);
  7099 call    0 returned 100%
  7100         1: 4801:        sDictPushTiny(dict, key, (smallt *) a);
  7101 call    0 returned 100%
  7102         -: 4802:      }
  7103         1: 4803:      break;
  7104         -: 4804:  }
  7105         -: 4805:}
  7106         -: 4806:
  7107         -: 4807:/**
  7108         -: 4808: * deserialize array from data
  7109         -: 4809: *
  7110         -: 4810: * a new array is allocated
  7111         -: 4811: *
  7112         -: 4812: * \param
  7113         -: 4813: *    array holding the elements
  7114         -: 4814: *    data serialized dictionary
  7115         -: 4815: */
  7116 function arrayNetDeserial called 53 returned 100% blocks executed 84%
  7117        53: 4816:internal void arrayNetDeserial(sArrayt **array, u8 **data, contextt *ctx, bool packed) {
  7118        53: 4817:  sUndefinedt *u = NULL;
  7119        53: 4818:  sBoolt *bo = NULL;
  7120        53: 4819:  double *D = NULL;
  7121        53: 4820:  sDoublet *Do = NULL;
  7122        53: 4821:  sDictt *d = NULL;
  7123        53: 4822:  sIntt *io = NULL;
  7124        53: 4823:  char *s = NULL;
  7125        53: 4824:  sStringt *so = NULL;
  7126        53: 4825:  sArrayt *a = NULL;
  7127        53: 4826:  sBytest *B = NULL;
  7128         -: 4827:  uint32_t count;
  7129         -: 4828:  uint32_t arrayCount;
  7130         -: 4829:
  7131        53: 4830:  if (packed) {
  7132 branch  0 taken 42% (fallthrough)
  7133 branch  1 taken 58%
  7134        22: 4831:    arrayCount = varintToUint(data);
  7135 call    0 returned 100%
  7136         -: 4832:  }
  7137         -: 4833:  else {
  7138        31: 4834:    if (ctx->nibble == lowNbl) {
  7139 branch  0 taken 90% (fallthrough)
  7140 branch  1 taken 10%
  7141        28: 4835:      arrayCount = netTypeVarintToUint(data);
  7142 call    0 returned 100%
  7143         -: 4836:    }
  7144         -: 4837:    else {
  7145         -: 4838:      // high nibble
  7146         3: 4839:      readTypeInHighNbl;
  7147 branch  0 taken 0% (fallthrough)
  7148 branch  1 taken 100%
  7149         3: 4840:      arrayCount = varintToUint(data);
  7150 call    0 returned 100%
  7151         -: 4841:    }
  7152         -: 4842:  }
  7153         -: 4843:
  7154        53: 4844:  if (!arrayCount) {
  7155 branch  0 taken 4% (fallthrough)
  7156 branch  1 taken 96%
  7157         2: 4845:    *array = allocSArray();;
  7158 call    0 returned 100%
  7159        55: 4846:    ret;
  7160         -: 4847:  }
  7161         -: 4848:
  7162        51: 4849:  bool inPack = false;
  7163         -: 4850:  u8 packedType;
  7164         -: 4851:  size_t packCount;
  7165       216: 4852:  loop(arrayCount) {
  7166 branch  0 taken 76%
  7167 branch  1 taken 24% (fallthrough)
  7168         -: 4853:    char type;
  7169       165: 4854:    if (inPack) {
  7170 branch  0 taken 18% (fallthrough)
  7171 branch  1 taken 82%
  7172        30: 4855:      type = packedType;
  7173         -: 4856:    }
  7174         -: 4857:    else {
  7175       135: 4858:      if (ctx->nibble == lowNbl) {
  7176 branch  0 taken 73% (fallthrough)
  7177 branch  1 taken 27%
  7178        99: 4859:        type = (**data) & 0xF;
  7179         -: 4860:      }
  7180         -: 4861:      else {
  7181         -: 4862:        // high nibble
  7182        36: 4863:        type = (*ctx->nblAddr) >> 4;
  7183         -: 4864:      }
  7184         -: 4865:    }
  7185         -: 4866:
  7186       165: 4867:    switch(type) {
  7187 branch  0 taken 18%
  7188 branch  1 taken 22%
  7189 branch  2 taken 1%
  7190 branch  3 taken 1%
  7191 branch  4 taken 17%
  7192 branch  5 taken 8%
  7193 branch  6 taken 1%
  7194 branch  7 taken 1%
  7195 branch  8 taken 5%
  7196 branch  9 taken 5%
  7197 branch 10 taken 5%
  7198 branch 11 taken 5%
  7199 branch 12 taken 5%
  7200 branch 13 taken 0%
  7201 branch 14 taken 3%
  7202 branch 15 taken 4%
  7203 branch 16 taken 0%
  7204         -: 4868:      case S_UNDEFINED:
  7205        29: 4869:        if (ctx->nibble == lowNbl) {
  7206 branch  0 taken 93% (fallthrough)
  7207 branch  1 taken 7%
  7208        27: 4870:          readTypeOnly;
  7209         -: 4871:        }
  7210         -: 4872:        else {
  7211         -: 4873:          // high nibble
  7212         2: 4874:          readTypeInHighNbl;
  7213 branch  0 taken 0% (fallthrough)
  7214 branch  1 taken 100%
  7215         -: 4875:        }
  7216        29: 4876:        u = allocSUndefined();
  7217 call    0 returned 100%
  7218        29: 4877:        sArrayPushTiny(array, (smallt *) u);
  7219 call    0 returned 100%
  7220        29: 4878:        break;
  7221         -: 4879:      case S_BOOL:
  7222        36: 4880:        if (!ctx->boolAddr) {
  7223 branch  0 taken 22% (fallthrough)
  7224 branch  1 taken 78%
  7225         -: 4881:          // new packed bools
  7226         8: 4882:          if (ctx->nibble == lowNbl) {
  7227 branch  0 taken 63% (fallthrough)
  7228 branch  1 taken 38%
  7229         5: 4883:            read4bPackedBool;
  7230         5: 4884:            bo = allocSBool((*ctx->boolAddr) & 0x10);
  7231 call    0 returned 100%
  7232         -: 4885:          }
  7233         -: 4886:          else {
  7234         -: 4887:            // high nibble
  7235         3: 4888:            readTypeInHighNbl;
  7236 branch  0 taken 0% (fallthrough)
  7237 branch  1 taken 100%
  7238         3: 4889:            read8bPackedBool;
  7239         3: 4890:            bo = allocSBool((*ctx->boolAddr) & 0x1);
  7240 call    0 returned 100%
  7241         -: 4891:          }
  7242         -: 4892:        }
  7243         -: 4893:        else {
  7244         -: 4894:          // there was a bool before this one, read bits in nibbles
  7245        28: 4895:          if (ctx->nibble == lowNbl) {
  7246 branch  0 taken 61% (fallthrough)
  7247 branch  1 taken 39%
  7248        17: 4896:            if (ctx->boolShift == 8) {
  7249 branch  0 taken 12% (fallthrough)
  7250 branch  1 taken 88%
  7251         2: 4897:              read4bPackedBool;
  7252         2: 4898:              bo = allocSBool((*ctx->boolAddr) & 0x10);
  7253 call    0 returned 100%
  7254         -: 4899:            }
  7255         -: 4900:            else {
  7256        15: 4901:              readTypeOnly;
  7257        15: 4902:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  7258 call    0 returned 100%
  7259         -: 4903:            }
  7260         -: 4904:          }
  7261         -: 4905:          else {
  7262         -: 4906:            // high nibble
  7263        11: 4907:            readTypeInHighNbl;
  7264 branch  0 taken 0% (fallthrough)
  7265 branch  1 taken 100%
  7266        11: 4908:            if (ctx->boolShift == 8) {
  7267 branch  0 taken 18% (fallthrough)
  7268 branch  1 taken 82%
  7269         2: 4909:              read8bPackedBool;
  7270         2: 4910:              bo = allocSBool((*ctx->boolAddr) & 0x1);
  7271 call    0 returned 100%
  7272         -: 4911:            }
  7273         -: 4912:            else {
  7274         9: 4913:              bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  7275 call    0 returned 100%
  7276         -: 4914:            }
  7277         -: 4915:          }
  7278         -: 4916:        }
  7279        36: 4917:        sArrayPushTiny(array, (smallt *) bo);
  7280 call    0 returned 100%
  7281        36: 4918:        break;
  7282         -: 4919:      case S_DICT:
  7283         2: 4920:        d = NULL;
  7284         2: 4921:        dictNetDeserial(&d, data, ctx, /*packed=*/false);
  7285 call    0 returned 100%
  7286         2: 4922:        sArrayPushTiny(array, (smallt *) d);
  7287 call    0 returned 100%
  7288         2: 4923:        break;
  7289         -: 4924:      case S_DOUBLE:
  7290         2: 4925:        if (ctx->nibble == lowNbl) {
  7291 branch  0 taken 50% (fallthrough)
  7292 branch  1 taken 50%
  7293         1: 4926:          readTypeOnly;
  7294         -: 4927:        }
  7295         -: 4928:        else {
  7296         -: 4929:          // high nibble
  7297         1: 4930:          readTypeInHighNbl;
  7298 branch  0 taken 0% (fallthrough)
  7299 branch  1 taken 100%
  7300         -: 4931:        }
  7301         2: 4932:        D      = (double *)(*data);
  7302         2: 4933:        *data += sizeof(double);
  7303         2: 4934:        Do     = allocSDouble(*D);
  7304 call    0 returned 100%
  7305         2: 4935:        sArrayPushTiny(array, (smallt *) Do);
  7306 call    0 returned 100%
  7307         2: 4936:        break;
  7308         -: 4937:      case S_INT: {
  7309         -: 4938:          u64 v;
  7310        28: 4939:          if (ctx->nibble == lowNbl) {
  7311 branch  0 taken 86% (fallthrough)
  7312 branch  1 taken 14%
  7313        24: 4940:            v = netTypeVarintToUint((u8**)data);
  7314 call    0 returned 100%
  7315         -: 4941:          }
  7316         -: 4942:          else {
  7317         -: 4943:            // high nibble
  7318         4: 4944:            readTypeInHighNbl;
  7319 branch  0 taken 0% (fallthrough)
  7320 branch  1 taken 100%
  7321         4: 4945:            v = varintToUint(data);
  7322 call    0 returned 100%
  7323         -: 4946:          }
  7324        28: 4947:          v  = (v >> 1) ^ (~(v & 1) + 1);
  7325        28: 4948:          io = allocSInt(v);
  7326 call    0 returned 100%
  7327        28: 4949:          sArrayPushTiny(array, (smallt *) io);
  7328 call    0 returned 100%
  7329         -: 4950:        }
  7330        28: 4951:        break;
  7331         -: 4952:      case S_STRING:
  7332        13: 4953:        if (ctx->nibble == lowNbl) {
  7333 branch  0 taken 69% (fallthrough)
  7334 branch  1 taken 31%
  7335         9: 4954:          readTypeOnly;
  7336         -: 4955:        }
  7337         -: 4956:        else {
  7338         -: 4957:          // high nibble
  7339         4: 4958:          readTypeInHighNbl;
  7340 branch  0 taken 0% (fallthrough)
  7341 branch  1 taken 100%
  7342         -: 4959:        }
  7343        13: 4960:        s      = (char *)(*data);
  7344        13: 4961:        *data += strlen(s)+1;
  7345        13: 4962:        so     = allocSStringTiny(s);
  7346 call    0 returned 100%
  7347        13: 4963:        sArrayPushTiny(array, (smallt *) so);
  7348 call    0 returned 100%
  7349        13: 4964:        break;
  7350         -: 4965:      case S_ARRAY:
  7351         2: 4966:        a = NULL;
  7352         2: 4967:        arrayNetDeserial(&a, data, ctx, /*packed=*/false);
  7353 call    0 returned 100%
  7354         2: 4968:        sArrayPushTiny(array, (smallt *) a);
  7355 call    0 returned 100%
  7356         2: 4969:        break;
  7357         -: 4970:      case S_BYTES:
  7358         2: 4971:        B      = allocSBytes();
  7359 call    0 returned 100%
  7360         2: 4972:        if (ctx->nibble == lowNbl) {
  7361 branch  0 taken 50% (fallthrough)
  7362 branch  1 taken 50%
  7363         1: 4973:          count  = netTypeVarintToUint((u8**)data);
  7364 call    0 returned 100%
  7365         -: 4974:        }
  7366         -: 4975:        else {
  7367         -: 4976:          // high nibble
  7368         1: 4977:          readTypeInHighNbl;
  7369 branch  0 taken 0% (fallthrough)
  7370 branch  1 taken 100%
  7371         1: 4978:          count  = varintToUint((u8**)data);
  7372 call    0 returned 100%
  7373         -: 4979:        }
  7374         2: 4980:        sBytesPushBuffer(&B, *data, count);
  7375 call    0 returned 100%
  7376         2: 4981:        *data += count;
  7377         2: 4982:        sArrayPushTiny(array, (smallt *) B);
  7378 call    0 returned 100%
  7379         2: 4983:        break;
  7380         -: 4984:      case PK_DICT:
  7381         8: 4985:        if (!inPack) {
  7382 branch  0 taken 25% (fallthrough)
  7383 branch  1 taken 75%
  7384         2: 4986:          inPack = true;
  7385         2: 4987:          if (ctx->nibble == lowNbl) {
  7386 branch  0 taken 50% (fallthrough)
  7387 branch  1 taken 50%
  7388         1: 4988:            packCount  = netTypeVarintToUint((u8**)data);
  7389 call    0 returned 100%
  7390         -: 4989:          }
  7391         -: 4990:          else {
  7392         -: 4991:            // high nibble
  7393         1: 4992:            readTypeInHighNbl;
  7394 branch  0 taken 0% (fallthrough)
  7395 branch  1 taken 100%
  7396         1: 4993:            packCount  = varintToUint((u8**)data);
  7397 call    0 returned 100%
  7398         -: 4994:          }
  7399         2: 4995:          packedType = PK_DICT;
  7400         -: 4996:        }
  7401         -: 4997:
  7402         8: 4998:        d = NULL;
  7403         8: 4999:        dictNetDeserial(&d, data, ctx, /*packed=*/true);
  7404 call    0 returned 100%
  7405         8: 5000:        sArrayPushTiny(array, (smallt *) d);
  7406 call    0 returned 100%
  7407         -: 5001:        // stop unpacking when packCount == 0
  7408         8: 5002:        packCount--;
  7409         8: 5003:        if (!packCount) inPack = false;
  7410 branch  0 taken 25% (fallthrough)
  7411 branch  1 taken 75%
  7412         8: 5004:        break;
  7413         -: 5005:      case PK_DOUBLE:
  7414         8: 5006:        if (!inPack) {
  7415 branch  0 taken 25% (fallthrough)
  7416 branch  1 taken 75%
  7417         2: 5007:          inPack = true;
  7418         2: 5008:          if (ctx->nibble == lowNbl) {
  7419 branch  0 taken 50% (fallthrough)
  7420 branch  1 taken 50%
  7421         1: 5009:            packCount  = netTypeVarintToUint((u8**)data);
  7422 call    0 returned 100%
  7423         -: 5010:          }
  7424         -: 5011:          else {
  7425         -: 5012:            // high nibble
  7426         1: 5013:            readTypeInHighNbl;
  7427 branch  0 taken 0% (fallthrough)
  7428 branch  1 taken 100%
  7429         1: 5014:            packCount  = varintToUint((u8**)data);
  7430 call    0 returned 100%
  7431         -: 5015:          }
  7432         2: 5016:          packedType = PK_DOUBLE;
  7433         -: 5017:        }
  7434         -: 5018:
  7435         8: 5019:        D      = (double *)(*data);
  7436         8: 5020:        *data += sizeof(double);
  7437         8: 5021:        Do     = allocSDouble(*D);
  7438 call    0 returned 100%
  7439         8: 5022:        sArrayPushTiny(array, (smallt *) Do);
  7440 call    0 returned 100%
  7441         -: 5023:        // stop unpacking when packCount == 0
  7442         8: 5024:        packCount--;
  7443         8: 5025:        if (!packCount) inPack = false;
  7444 branch  0 taken 25% (fallthrough)
  7445 branch  1 taken 75%
  7446         8: 5026:        break;
  7447         -: 5027:      case PK_INT:
  7448         8: 5028:        if (!inPack) {
  7449 branch  0 taken 25% (fallthrough)
  7450 branch  1 taken 75%
  7451         2: 5029:          inPack = true;
  7452         2: 5030:          if (ctx->nibble == lowNbl) {
  7453 branch  0 taken 50% (fallthrough)
  7454 branch  1 taken 50%
  7455         1: 5031:            packCount  = netTypeVarintToUint((u8**)data);
  7456 call    0 returned 100%
  7457         -: 5032:          }
  7458         -: 5033:          else {
  7459         -: 5034:            // high nibble
  7460         1: 5035:            readTypeInHighNbl;
  7461 branch  0 taken 0% (fallthrough)
  7462 branch  1 taken 100%
  7463         1: 5036:            packCount  = varintToUint((u8**)data);
  7464 call    0 returned 100%
  7465         -: 5037:          }
  7466         2: 5038:          packedType = PK_INT;
  7467         -: 5039:        }
  7468         -: 5040:
  7469         8: 5041:        u64 v = varintToUint(data);
  7470 call    0 returned 100%
  7471         8: 5042:        v     = (v >> 1) ^ (~(v & 1) + 1);
  7472         8: 5043:        io     = allocSInt(v);
  7473 call    0 returned 100%
  7474         8: 5044:        sArrayPushTiny(array, (smallt *) io);
  7475 call    0 returned 100%
  7476         -: 5045:        // stop unpacking when packCount == 0
  7477         8: 5046:        packCount--;
  7478         8: 5047:        if (!packCount) inPack = false;
  7479 branch  0 taken 25% (fallthrough)
  7480 branch  1 taken 75%
  7481         8: 5048:        break;
  7482         -: 5049:      case PK_STRING:
  7483         8: 5050:        if (!inPack) {
  7484 branch  0 taken 25% (fallthrough)
  7485 branch  1 taken 75%
  7486         2: 5051:          inPack = true;
  7487         2: 5052:          if (ctx->nibble == lowNbl) {
  7488 branch  0 taken 50% (fallthrough)
  7489 branch  1 taken 50%
  7490         1: 5053:            packCount  = netTypeVarintToUint((u8**)data);
  7491 call    0 returned 100%
  7492         -: 5054:          }
  7493         -: 5055:          else {
  7494         -: 5056:            // high nibble
  7495         1: 5057:            readTypeInHighNbl;
  7496 branch  0 taken 0% (fallthrough)
  7497 branch  1 taken 100%
  7498         1: 5058:            packCount  = varintToUint((u8**)data);
  7499 call    0 returned 100%
  7500         -: 5059:          }
  7501         2: 5060:          packedType = PK_STRING;
  7502         -: 5061:        }
  7503         -: 5062:
  7504         8: 5063:        s      = (char *)(*data);
  7505         8: 5064:        *data += strlen(s)+1;
  7506         8: 5065:        so     = allocSStringTiny(s);
  7507 call    0 returned 100%
  7508         8: 5066:        sArrayPushTiny(array, (smallt *) so);
  7509 call    0 returned 100%
  7510         -: 5067:        // stop unpacking when packCount == 0
  7511         8: 5068:        packCount--;
  7512         8: 5069:        if (!packCount) inPack = false;
  7513 branch  0 taken 25% (fallthrough)
  7514 branch  1 taken 75%
  7515         8: 5070:        break;
  7516         -: 5071:      case PK_ARRAY:
  7517         8: 5072:        if (!inPack) {
  7518 branch  0 taken 25% (fallthrough)
  7519 branch  1 taken 75%
  7520         2: 5073:          inPack = true;
  7521         2: 5074:          if (ctx->nibble == lowNbl) {
  7522 branch  0 taken 50% (fallthrough)
  7523 branch  1 taken 50%
  7524         1: 5075:            packCount  = netTypeVarintToUint((u8**)data);
  7525 call    0 returned 100%
  7526         -: 5076:          }
  7527         -: 5077:          else {
  7528         -: 5078:            // high nibble
  7529         1: 5079:            readTypeInHighNbl;
  7530 branch  0 taken 0% (fallthrough)
  7531 branch  1 taken 100%
  7532         1: 5080:            packCount  = varintToUint((u8**)data);
  7533 call    0 returned 100%
  7534         -: 5081:          }
  7535         2: 5082:          packedType = PK_ARRAY;
  7536         -: 5083:        }
  7537         -: 5084:
  7538         8: 5085:        a = NULL;
  7539         8: 5086:        arrayNetDeserial(&a, data, ctx, /*packed=*/true);
  7540 call    0 returned 100%
  7541         8: 5087:        sArrayPushTiny(array, (smallt *) a);
  7542 call    0 returned 100%
  7543         -: 5088:        // stop unpacking when packCount == 0
  7544         8: 5089:        packCount--;
  7545         8: 5090:        if (!packCount) inPack = false;
  7546 branch  0 taken 25% (fallthrough)
  7547 branch  1 taken 75%
  7548         8: 5091:        break;
  7549         -: 5092:      case PK_BYTES:
  7550     #####: 5093:        if (!inPack) {
  7551 branch  0 never executed
  7552 branch  1 never executed
  7553     #####: 5094:          inPack = true;
  7554     #####: 5095:          if (ctx->nibble == lowNbl) {
  7555 branch  0 never executed
  7556 branch  1 never executed
  7557     #####: 5096:            packCount  = netTypeVarintToUint((u8**)data);
  7558 call    0 never executed
  7559         -: 5097:          }
  7560         -: 5098:          else {
  7561         -: 5099:            // high nibble
  7562     #####: 5100:            readTypeInHighNbl;
  7563 branch  0 never executed
  7564 branch  1 never executed
  7565     #####: 5101:            packCount  = varintToUint((u8**)data);
  7566 call    0 never executed
  7567         -: 5102:          }
  7568     #####: 5103:          packedType = PK_BYTES;
  7569         -: 5104:        }
  7570         -: 5105:
  7571     #####: 5106:        B      = allocSBytes();
  7572 call    0 never executed
  7573     #####: 5107:        count  = varintToUint((u8**)data);
  7574 call    0 never executed
  7575     #####: 5108:        sBytesPushBuffer(&B, *data, count);
  7576 call    0 never executed
  7577     #####: 5109:        *data += count;
  7578     #####: 5110:        sArrayPushTiny(array, (smallt *) B);
  7579 call    0 never executed
  7580         -: 5111:        // stop unpacking when packCount == 0
  7581     #####: 5112:        packCount--;
  7582     #####: 5113:        if (!packCount) inPack = false;
  7583 branch  0 never executed
  7584 branch  1 never executed
  7585     #####: 5114:        break;
  7586         -: 5115:      case UNIFORM_DICT:
  7587         5: 5116:        d = NULL;
  7588         5: 5117:        uniformDictNetDeserial(&d, data, ctx, /*packed=*/false);
  7589 call    0 returned 100%
  7590         5: 5118:        sArrayPushTiny(array, (smallt *) d);
  7591 call    0 returned 100%
  7592         5: 5119:        break;
  7593         -: 5120:      case UNIFORM_ARRAY:
  7594         6: 5121:        a = NULL;
  7595         6: 5122:        uniformArrayNetDeserial(&a, data, ctx, /*packed=*/false);
  7596 call    0 returned 100%
  7597         6: 5123:        sArrayPushTiny(array, (smallt *) a);
  7598 call    0 returned 100%
  7599         6: 5124:        break;
  7600         -: 5125:    }
  7601         -: 5126:  }
  7602         -: 5127:}
  7603         -: 5128:
  7604 function uniformArrayNetDeserial called 25 returned 100% blocks executed 99%
  7605        25: 5129:internal void uniformArrayNetDeserial(sArrayt **array, u8 **data, contextt *ctx, bool packed) {
  7606        25: 5130:  sUndefinedt *u = NULL;
  7607        25: 5131:  sBoolt *bo = NULL;
  7608        25: 5132:  double *D = NULL;
  7609        25: 5133:  sDoublet *Do = NULL;
  7610        25: 5134:  sDictt *d = NULL;
  7611        25: 5135:  sIntt *io = NULL;
  7612        25: 5136:  char *s = NULL;
  7613        25: 5137:  sStringt *so = NULL;
  7614        25: 5138:  sArrayt *a = NULL;
  7615        25: 5139:  sBytest *B = NULL;
  7616         -: 5140:  uint32_t count;
  7617         -: 5141:  uint32_t arrayCount;
  7618         -: 5142:  u8 type;
  7619         -: 5143:
  7620        25: 5144:  if (packed) {
  7621 branch  0 taken 8% (fallthrough)
  7622 branch  1 taken 92%
  7623         2: 5145:    type = (**data) & 0xF;
  7624         2: 5146:    arrayCount = netTypeVarintToUint(data);
  7625 call    0 returned 100%
  7626         -: 5147:  }
  7627         -: 5148:  else {
  7628        23: 5149:    if (ctx->nibble == lowNbl) {
  7629 branch  0 taken 78% (fallthrough)
  7630 branch  1 taken 22%
  7631        18: 5150:      type = (**data) >> 4;
  7632        18: 5151:      (*data)++;
  7633        18: 5152:      arrayCount = varintToUint(data);
  7634 call    0 returned 100%
  7635         -: 5153:    }
  7636         -: 5154:    else {
  7637         5: 5155:      readTypeInHighNbl;
  7638 branch  0 taken 0% (fallthrough)
  7639 branch  1 taken 100%
  7640         5: 5156:      type = (**data) & 0xF;
  7641         5: 5157:      arrayCount = netTypeVarintToUint(data);
  7642 call    0 returned 100%
  7643         -: 5158:    }
  7644         -: 5159:  }
  7645         -: 5160:
  7646        25: 5161:  if (!arrayCount) {
  7647 branch  0 taken 8% (fallthrough)
  7648 branch  1 taken 92%
  7649         2: 5162:    *array = allocSArray();;
  7650 call    0 returned 100%
  7651        27: 5163:    ret;
  7652         -: 5164:  }
  7653         -: 5165:
  7654        23: 5166:  switch(type) {
  7655 branch  0 taken 4%
  7656 branch  1 taken 9%
  7657 branch  2 taken 4%
  7658 branch  3 taken 4%
  7659 branch  4 taken 48%
  7660 branch  5 taken 4%
  7661 branch  6 taken 13%
  7662 branch  7 taken 4%
  7663 branch  8 taken 4%
  7664 branch  9 taken 4%
  7665 branch 10 taken 0%
  7666         -: 5167:    case S_UNDEFINED:
  7667         7: 5168:      loop(arrayCount) {
  7668 branch  0 taken 86%
  7669 branch  1 taken 14% (fallthrough)
  7670         6: 5169:        u = allocSUndefined();
  7671 call    0 returned 100%
  7672         6: 5170:        sArrayPushTiny(array, (smallt *) u);
  7673 call    0 returned 100%
  7674         -: 5171:      }
  7675         1: 5172:      break;
  7676         -: 5173:    case S_BOOL:
  7677        16: 5174:      loop(arrayCount) {
  7678 branch  0 taken 88%
  7679 branch  1 taken 13% (fallthrough)
  7680        14: 5175:        if (!ctx->boolAddr) {
  7681 branch  0 taken 14% (fallthrough)
  7682 branch  1 taken 86%
  7683         2: 5176:          read8bPackedBool;
  7684         2: 5177:          ctx->boolShift = 0;
  7685         -: 5178:        }
  7686        14: 5179:        if (ctx->boolShift == 8) {
  7687 branch  0 taken 7% (fallthrough)
  7688 branch  1 taken 93%
  7689         1: 5180:          read8bPackedBool;
  7690         1: 5181:          bo = allocSBool((*ctx->boolAddr) & 0x1);
  7691 call    0 returned 100%
  7692         -: 5182:        }
  7693         -: 5183:        else {
  7694        13: 5184:          bo = allocSBool((*ctx->boolAddr) & (0x1 << (ctx->boolShift++)));
  7695 call    0 returned 100%
  7696         -: 5185:        }
  7697        14: 5186:        sArrayPushTiny(array, (smallt *) bo);
  7698 call    0 returned 100%
  7699         -: 5187:      }
  7700         2: 5188:      break;
  7701         -: 5189:    case S_DICT:
  7702         3: 5190:      loop(arrayCount) {
  7703 branch  0 taken 67%
  7704 branch  1 taken 33% (fallthrough)
  7705         2: 5191:        d = NULL;
  7706         2: 5192:        dictNetDeserial(&d, data, ctx, /*packed=*/true);
  7707 call    0 returned 100%
  7708         2: 5193:        sArrayPushTiny(array, (smallt *) d);
  7709 call    0 returned 100%
  7710         -: 5194:      }
  7711         1: 5195:      break;
  7712         -: 5196:    case S_DOUBLE:
  7713         4: 5197:      loop(arrayCount) {
  7714 branch  0 taken 75%
  7715 branch  1 taken 25% (fallthrough)
  7716         3: 5198:        D      = (double *)(*data);
  7717         3: 5199:        *data += sizeof(double);
  7718         3: 5200:        Do     = allocSDouble(*D);
  7719 call    0 returned 100%
  7720         3: 5201:        sArrayPushTiny(array, (smallt *) Do);
  7721 call    0 returned 100%
  7722         -: 5202:      }
  7723         1: 5203:      break;
  7724         -: 5204:    case S_INT:
  7725        49: 5205:      loop(arrayCount) {
  7726 branch  0 taken 78%
  7727 branch  1 taken 22% (fallthrough)
  7728        38: 5206:        u64 v = varintToUint(data);
  7729 call    0 returned 100%
  7730        38: 5207:        v     = (v >> 1) ^ (~(v & 1) + 1);
  7731        38: 5208:        io    = allocSInt(v);
  7732 call    0 returned 100%
  7733        38: 5209:        sArrayPushTiny(array, (smallt *) io);
  7734 call    0 returned 100%
  7735         -: 5210:      }
  7736        11: 5211:      break;
  7737         -: 5212:    case S_STRING:
  7738         4: 5213:      loop(arrayCount) {
  7739 branch  0 taken 75%
  7740 branch  1 taken 25% (fallthrough)
  7741         3: 5214:        s      = (char *)(*data);
  7742         3: 5215:        *data += strlen(s)+1;
  7743         3: 5216:        so     = allocSStringTiny(s);
  7744 call    0 returned 100%
  7745         3: 5217:        sArrayPushTiny(array, (smallt *) so);
  7746 call    0 returned 100%
  7747         -: 5218:      }
  7748         1: 5219:      break;
  7749         -: 5220:    case S_ARRAY:
  7750         8: 5221:      loop(arrayCount) {
  7751 branch  0 taken 63%
  7752 branch  1 taken 38% (fallthrough)
  7753         5: 5222:        a = NULL;
  7754         5: 5223:        arrayNetDeserial(&a, data, ctx, /*packed=*/true);
  7755 call    0 returned 100%
  7756         5: 5224:        sArrayPushTiny(array, (smallt *) a);
  7757 call    0 returned 100%
  7758         -: 5225:      }
  7759         3: 5226:      break;
  7760         -: 5227:    case S_BYTES:
  7761         3: 5228:      loop(arrayCount) {
  7762 branch  0 taken 67%
  7763 branch  1 taken 33% (fallthrough)
  7764         2: 5229:        B      = allocSBytes();
  7765 call    0 returned 100%
  7766         2: 5230:        count  = varintToUint((u8**)data);
  7767 call    0 returned 100%
  7768         2: 5231:        sBytesPushBuffer(&B, *data, count);
  7769 call    0 returned 100%
  7770         2: 5232:        *data += count;
  7771         2: 5233:        sArrayPushTiny(array, (smallt *) B);
  7772 call    0 returned 100%
  7773         -: 5234:      }
  7774         1: 5235:      break;
  7775         -: 5236:    case UNIFORM_DICT:
  7776         3: 5237:      loop(arrayCount) {
  7777 branch  0 taken 67%
  7778 branch  1 taken 33% (fallthrough)
  7779         2: 5238:        d = NULL;
  7780         2: 5239:        uniformDictNetDeserial(&d, data, ctx, /*packed=*/true);
  7781 call    0 returned 100%
  7782         2: 5240:        sArrayPushTiny(array, (smallt *) d);
  7783 call    0 returned 100%
  7784         -: 5241:      }
  7785         1: 5242:      break;
  7786         -: 5243:    case UNIFORM_ARRAY:
  7787         2: 5244:      loop(arrayCount) {
  7788 branch  0 taken 50%
  7789 branch  1 taken 50% (fallthrough)
  7790         1: 5245:        a = NULL;
  7791         1: 5246:        uniformArrayNetDeserial(&a, data, ctx, /*packed=*/true);
  7792 call    0 returned 100%
  7793         1: 5247:        sArrayPushTiny(array, (smallt *) a);
  7794 call    0 returned 100%
  7795         -: 5248:      }
  7796         1: 5249:      break;
  7797         -: 5250:  }
  7798         -: 5251:}
  7799         -: 5252:
  7800 function deserialNetSerial called 87 returned 100% blocks executed 91%
  7801        87: 5253:internal smallJsont* deserialNetSerial(smallJsont *self, smallBytest *data) {
  7802         -: 5254:
  7803        87: 5255:  if (!data or !data->B or !data->B->count) {
  7804 branch  0 taken 100% (fallthrough)
  7805 branch  1 taken 0%
  7806 branch  2 taken 100% (fallthrough)
  7807 branch  3 taken 0%
  7808 branch  4 taken 1% (fallthrough)
  7809 branch  5 taken 99%
  7810         1: 5256:    ret self;
  7811         -: 5257:  }
  7812         -: 5258:
  7813        86: 5259:  smallt *o = netDeserial(data->B);
  7814 call    0 returned 100%
  7815         -: 5260:
  7816        86: 5261:  if (!o) {
  7817 branch  0 taken 0% (fallthrough)
  7818 branch  1 taken 100%
  7819     #####: 5262:    ret self;
  7820         -: 5263:  }
  7821         -: 5264:
  7822        86: 5265:  freeG(self);
  7823 call    0 returned 100%
  7824         -: 5266:
  7825        86: 5267:  setsoG(self, o);
  7826 call    0 returned 100%
  7827         -: 5268:
  7828        86: 5269:  ret self;
  7829         -: 5270:}
  7830         -: 5271:
  7831         -: 5272:// vim: set expandtab ts=2 sw=2:
  7832         -: 5273:
  7833 function checkLibsheepyVersionNetSerial called 0 returned 0% blocks executed 0%
  7834     #####: 5274:bool checkLibsheepyVersionNetSerial(const char *currentLibsheepyVersion) {
  7835     #####: 5275:  return eqG(currentLibsheepyVersion, LIBSHEEPY_VERSION);
  7836 call    0 never executed
  7837         -: 5276:}
  7838         -: 5277: