LCOV - code coverage report
Current view: top level - libreoffice/workdir/unxlngi6.pro/UnpackedTarball/python3/Python - asdl.c (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 36 66.7 %
Date: 2012-12-17 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include "Python.h"
       2             : #include "asdl.h"
       3             : 
       4             : asdl_seq *
       5         359 : asdl_seq_new(Py_ssize_t size, PyArena *arena)
       6             : {
       7         359 :     asdl_seq *seq = NULL;
       8         359 :     size_t n = (size ? (sizeof(void *) * (size - 1)) : 0);
       9             : 
      10             :     /* check size is sane */
      11         359 :     if (size < 0 || size == INT_MIN ||
      12         293 :         (size && ((size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
      13           0 :         PyErr_NoMemory();
      14           0 :         return NULL;
      15             :     }
      16             : 
      17             :     /* check if size can be added safely */
      18         359 :     if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
      19           0 :         PyErr_NoMemory();
      20           0 :         return NULL;
      21             :     }
      22             : 
      23         359 :     n += sizeof(asdl_seq);
      24             : 
      25         359 :     seq = (asdl_seq *)PyArena_Malloc(arena, n);
      26         359 :     if (!seq) {
      27           0 :         PyErr_NoMemory();
      28           0 :         return NULL;
      29             :     }
      30         359 :     memset(seq, 0, n);
      31         359 :     seq->size = size;
      32         359 :     return seq;
      33             : }
      34             : 
      35             : asdl_int_seq *
      36          20 : asdl_int_seq_new(Py_ssize_t size, PyArena *arena)
      37             : {
      38          20 :     asdl_int_seq *seq = NULL;
      39          20 :     size_t n = (size ? (sizeof(void *) * (size - 1)) : 0);
      40             : 
      41             :     /* check size is sane */
      42          20 :     if (size < 0 || size == INT_MIN ||
      43          20 :         (size && ((size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
      44           0 :             PyErr_NoMemory();
      45           0 :             return NULL;
      46             :     }
      47             : 
      48             :     /* check if size can be added safely */
      49          20 :     if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
      50           0 :         PyErr_NoMemory();
      51           0 :         return NULL;
      52             :     }
      53             : 
      54          20 :     n += sizeof(asdl_seq);
      55             : 
      56          20 :     seq = (asdl_int_seq *)PyArena_Malloc(arena, n);
      57          20 :     if (!seq) {
      58           0 :         PyErr_NoMemory();
      59           0 :         return NULL;
      60             :     }
      61          20 :     memset(seq, 0, n);
      62          20 :     seq->size = size;
      63          20 :     return seq;
      64             : }

Generated by: LCOV version 1.10