• Home
  • Raw
  • Download

Lines Matching +full:- +full:rf

93         if ((p)->ptr != (p)->end || w_reserve((p), 1))  \
94 *(p)->ptr++ = (c); \
100 assert(p->fp != NULL); in w_flush()
101 fwrite(p->buf, 1, p->ptr - p->buf, p->fp); in w_flush()
102 p->ptr = p->buf; in w_flush()
109 if (p->ptr == NULL) in w_reserve()
111 if (p->fp != NULL) { in w_reserve()
113 return needed <= p->end - p->ptr; in w_reserve()
115 assert(p->str != NULL); in w_reserve()
116 pos = p->ptr - p->buf; in w_reserve()
117 size = PyBytes_GET_SIZE(p->str); in w_reserve()
123 if (delta > PY_SSIZE_T_MAX - size) { in w_reserve()
124 p->error = WFERR_NOMEMORY; in w_reserve()
128 if (_PyBytes_Resize(&p->str, size) != 0) { in w_reserve()
129 p->end = p->ptr = p->buf = NULL; in w_reserve()
133 p->buf = PyBytes_AS_STRING(p->str); in w_reserve()
134 p->ptr = p->buf + pos; in w_reserve()
135 p->end = p->buf + size; in w_reserve()
144 if (!n || p->ptr == NULL) in w_string()
146 m = p->end - p->ptr; in w_string()
147 if (p->fp != NULL) { in w_string()
149 memcpy(p->ptr, s, n); in w_string()
150 p->ptr += n; in w_string()
154 fwrite(s, 1, n, p->fp); in w_string()
158 if (n <= m || w_reserve(p, n - m)) { in w_string()
159 memcpy(p->ptr, s, n); in w_string()
160 p->ptr += n; in w_string()
186 (p)->depth--; \
187 (p)->error = WFERR_UNMARSHALLABLE; \
216 #define PyLong_MARSHAL_MASK (PyLong_MARSHAL_BASE - 1)
240 l = (n-1) * PyLong_MARSHAL_RATIO; in w_PyLong()
241 d = ob->ob_digit[n-1]; in w_PyLong()
248 p->depth--; in w_PyLong()
249 p->error = WFERR_UNMARSHALLABLE; in w_PyLong()
252 w_long((long)(Py_SIZE(ob) > 0 ? l : -l), p); in w_PyLong()
254 for (i=0; i < n-1; i++) { in w_PyLong()
255 d = ob->ob_digit[i]; in w_PyLong()
262 d = ob->ob_digit[n-1]; in w_PyLong()
274 p->error = WFERR_UNMARSHALLABLE; in w_float_bin()
285 p->error = WFERR_NOMEMORY; in w_float_str()
298 if (p->version < 3 || p->hashtable == NULL) in w_ref()
305 entry = _Py_hashtable_get_entry(p->hashtable, v); in w_ref()
308 w = (int)(uintptr_t)entry->value; in w_ref()
315 size_t s = p->hashtable->nentries; in w_ref()
323 if (_Py_hashtable_set(p->hashtable, v, (void *)(uintptr_t)w) < 0) { in w_ref()
331 p->error = WFERR_UNMARSHALLABLE; in w_ref()
343 p->depth++; in w_object()
345 if (p->depth > MAX_MARSHAL_STACK_DEPTH) { in w_object()
346 p->error = WFERR_NESTEDTOODEEP; in w_object()
369 p->depth--; in w_object()
386 if (y && y != -1) { in w_complex_object()
399 if (p->version > 1) { in w_complex_object()
409 if (p->version > 1) { in w_complex_object()
425 if (p->version >= 4 && PyUnicode_IS_ASCII(v)) { in w_complex_object()
448 p->depth--; in w_complex_object()
449 p->error = WFERR_UNMARSHALLABLE; in w_complex_object()
452 if (p->version >= 3 && PyUnicode_CHECK_INTERNED(v)) in w_complex_object()
462 if (p->version >= 4 && n < 256) { in w_complex_object()
512 w_long(co->co_argcount, p); in w_complex_object()
513 w_long(co->co_posonlyargcount, p); in w_complex_object()
514 w_long(co->co_kwonlyargcount, p); in w_complex_object()
515 w_long(co->co_nlocals, p); in w_complex_object()
516 w_long(co->co_stacksize, p); in w_complex_object()
517 w_long(co->co_flags, p); in w_complex_object()
518 w_object(co->co_code, p); in w_complex_object()
519 w_object(co->co_consts, p); in w_complex_object()
520 w_object(co->co_names, p); in w_complex_object()
521 w_object(co->co_varnames, p); in w_complex_object()
522 w_object(co->co_freevars, p); in w_complex_object()
523 w_object(co->co_cellvars, p); in w_complex_object()
524 w_object(co->co_filename, p); in w_complex_object()
525 w_object(co->co_name, p); in w_complex_object()
526 w_long(co->co_firstlineno, p); in w_complex_object()
527 w_object(co->co_linetable, p); in w_complex_object()
530 /* Write unknown bytes-like objects as a bytes object */ in w_complex_object()
534 p->depth--; in w_complex_object()
535 p->error = WFERR_UNMARSHALLABLE; in w_complex_object()
544 p->error = WFERR_UNMARSHALLABLE; in w_complex_object()
559 wf->hashtable = _Py_hashtable_new_full(_Py_hashtable_hash_ptr, in w_init_refs()
562 if (wf->hashtable == NULL) { in w_init_refs()
564 return -1; in w_init_refs()
573 if (wf->hashtable != NULL) { in w_clear_refs()
574 _Py_hashtable_destroy(wf->hashtable); in w_clear_refs()
619 PyObject *readable; /* Stream-like object being read from */
630 Py_ssize_t read = -1; in r_string()
632 if (p->ptr != NULL) { in r_string()
634 const char *res = p->ptr; in r_string()
635 Py_ssize_t left = p->end - p->ptr; in r_string()
641 p->ptr += n; in r_string()
644 if (p->buf == NULL) { in r_string()
645 p->buf = PyMem_Malloc(n); in r_string()
646 if (p->buf == NULL) { in r_string()
650 p->buf_size = n; in r_string()
652 else if (p->buf_size < n) { in r_string()
653 char *tmp = PyMem_Realloc(p->buf, n); in r_string()
658 p->buf = tmp; in r_string()
659 p->buf_size = n; in r_string()
662 if (!p->readable) { in r_string()
663 assert(p->fp != NULL); in r_string()
664 read = fread(p->buf, 1, n, p->fp); in r_string()
671 if (PyBuffer_FillInfo(&buf, NULL, p->buf, n, 0, PyBUF_CONTIG) == -1) in r_string()
677 res = _PyObject_CallMethodId(p->readable, &PyId_readinto, "N", mview); in r_string()
696 return p->buf; in r_string()
704 if (p->ptr != NULL) { in r_byte()
705 if (p->ptr < p->end) in r_byte()
706 c = (unsigned char) *p->ptr++; in r_byte()
709 if (!p->readable) { in r_byte()
710 assert(p->fp); in r_byte()
711 c = getc(p->fp); in r_byte()
724 short x = -1; in r_short()
731 /* Sign-extension, in case short greater than 16 bits */ in r_short()
732 x |= -(x & 0x8000); in r_short()
740 long x = -1; in r_long()
750 /* Sign extension for 64-bit machines */ in r_long()
751 x |= -(x & 0x80000000L); in r_long()
783 if (n < -SIZE32_MAX || n > SIZE32_MAX) { in r_PyLong()
789 size = 1 + (Py_ABS(n) - 1) / PyLong_MARSHAL_RATIO; in r_PyLong()
790 shorts_in_top_digit = 1 + (Py_ABS(n) - 1) % PyLong_MARSHAL_RATIO; in r_PyLong()
795 Py_SET_SIZE(ob, n > 0 ? size : -size); in r_PyLong()
797 for (i = 0; i < size-1; i++) { in r_PyLong()
809 ob->ob_digit[i] = d; in r_PyLong()
822 if (md == 0 && j == shorts_in_top_digit - 1) { in r_PyLong()
836 ob->ob_digit[size-1] = d; in r_PyLong()
850 return -1; in r_float_bin()
866 return -1; in r_float_str()
870 return -1; in r_float_str()
877 /* allocate the reflist index for a new object. Return -1 on failure */
882 Py_ssize_t idx = PyList_GET_SIZE(p->refs); in r_ref_reserve()
885 return -1; in r_ref_reserve()
887 if (PyList_Append(p->refs, Py_None) < 0) in r_ref_reserve()
888 return -1; in r_ref_reserve()
897 * if 'o' was non-NULL, and the function succeeds, 'o' is returned.
898 * if 'o' was non-NULL, and the function fails, 'o' is released and
906 PyObject *tmp = PyList_GET_ITEM(p->refs, idx); in r_ref_insert()
908 PyList_SET_ITEM(p->refs, idx, o); in r_ref_insert()
916 * after having loaded its sub-objects.
924 if (PyList_Append(p->refs, o) < 0) { in r_ref()
949 p->depth++; in r_object()
951 if (p->depth > MAX_MARSHAL_STACK_DEPTH) { in r_object()
952 p->depth--; in r_object()
1014 if (x == -1.0 && PyErr_Occurred()) in r_object()
1024 if (x == -1.0 && PyErr_Occurred()) in r_object()
1035 if (c.real == -1.0 && PyErr_Occurred()) in r_object()
1038 if (c.imag == -1.0 && PyErr_Occurred()) in r_object()
1049 if (c.real == -1.0 && PyErr_Occurred()) in r_object()
1052 if (c.imag == -1.0 && PyErr_Occurred()) in r_object()
1288 if (PySet_Add(v, v2) == -1) { in r_object()
1327 /* XXX ignore long->int overflows for now */ in r_object()
1372 if (firstlineno == -1 && PyErr_Occurred()) in r_object()
1402 if (n < 0 || n >= PyList_GET_SIZE(p->refs)) { in r_object()
1403 if (n == -1 && PyErr_Occurred()) in r_object()
1408 v = PyList_GET_ITEM(p->refs, n); in r_object()
1424 p->depth--; in r_object()
1436 if (p->ptr && p->end) { in read_object()
1437 if (PySys_Audit("marshal.loads", "y#", p->ptr, (Py_ssize_t)(p->end - p->ptr)) < 0) { in read_object()
1440 } else if (p->fp || p->readable) { in read_object()
1454 RFILE rf; in PyMarshal_ReadShortFromFile() local
1457 rf.readable = NULL; in PyMarshal_ReadShortFromFile()
1458 rf.fp = fp; in PyMarshal_ReadShortFromFile()
1459 rf.end = rf.ptr = NULL; in PyMarshal_ReadShortFromFile()
1460 rf.buf = NULL; in PyMarshal_ReadShortFromFile()
1461 res = r_short(&rf); in PyMarshal_ReadShortFromFile()
1462 if (rf.buf != NULL) in PyMarshal_ReadShortFromFile()
1463 PyMem_Free(rf.buf); in PyMarshal_ReadShortFromFile()
1470 RFILE rf; in PyMarshal_ReadLongFromFile() local
1472 rf.fp = fp; in PyMarshal_ReadLongFromFile()
1473 rf.readable = NULL; in PyMarshal_ReadLongFromFile()
1474 rf.ptr = rf.end = NULL; in PyMarshal_ReadLongFromFile()
1475 rf.buf = NULL; in PyMarshal_ReadLongFromFile()
1476 res = r_long(&rf); in PyMarshal_ReadLongFromFile()
1477 if (rf.buf != NULL) in PyMarshal_ReadLongFromFile()
1478 PyMem_Free(rf.buf); in PyMarshal_ReadLongFromFile()
1488 return -1; in getfilesize()
1497 /* If we can get the size of the file up-front, and it's reasonably small,
1521 * REASONABLE_FILE_LIMIT or malloc failed -- read a byte at a time. in PyMarshal_ReadLastObjectFromFile()
1531 RFILE rf; in PyMarshal_ReadObjectFromFile() local
1533 rf.fp = fp; in PyMarshal_ReadObjectFromFile()
1534 rf.readable = NULL; in PyMarshal_ReadObjectFromFile()
1535 rf.depth = 0; in PyMarshal_ReadObjectFromFile()
1536 rf.ptr = rf.end = NULL; in PyMarshal_ReadObjectFromFile()
1537 rf.buf = NULL; in PyMarshal_ReadObjectFromFile()
1538 rf.refs = PyList_New(0); in PyMarshal_ReadObjectFromFile()
1539 if (rf.refs == NULL) in PyMarshal_ReadObjectFromFile()
1541 result = read_object(&rf); in PyMarshal_ReadObjectFromFile()
1542 Py_DECREF(rf.refs); in PyMarshal_ReadObjectFromFile()
1543 if (rf.buf != NULL) in PyMarshal_ReadObjectFromFile()
1544 PyMem_Free(rf.buf); in PyMarshal_ReadObjectFromFile()
1551 RFILE rf; in PyMarshal_ReadObjectFromString() local
1553 rf.fp = NULL; in PyMarshal_ReadObjectFromString()
1554 rf.readable = NULL; in PyMarshal_ReadObjectFromString()
1555 rf.ptr = str; in PyMarshal_ReadObjectFromString()
1556 rf.end = str + len; in PyMarshal_ReadObjectFromString()
1557 rf.buf = NULL; in PyMarshal_ReadObjectFromString()
1558 rf.depth = 0; in PyMarshal_ReadObjectFromString()
1559 rf.refs = PyList_New(0); in PyMarshal_ReadObjectFromString()
1560 if (rf.refs == NULL) in PyMarshal_ReadObjectFromString()
1562 result = read_object(&rf); in PyMarshal_ReadObjectFromString()
1563 Py_DECREF(rf.refs); in PyMarshal_ReadObjectFromString()
1564 if (rf.buf != NULL) in PyMarshal_ReadObjectFromString()
1565 PyMem_Free(rf.buf); in PyMarshal_ReadObjectFromString()
1593 if (_PyBytes_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)) < 0) in PyMarshal_WriteObjectToString()
1624 ValueError exception is raised - but garbage data will also be written
1633 /* XXX Quick hack -- need to do this differently */ in marshal_dump_impl()
1669 RFILE rf; in marshal_load() local
1684 Py_TYPE(data)->tp_name); in marshal_load()
1688 rf.depth = 0; in marshal_load()
1689 rf.fp = NULL; in marshal_load()
1690 rf.readable = file; in marshal_load()
1691 rf.ptr = rf.end = NULL; in marshal_load()
1692 rf.buf = NULL; in marshal_load()
1693 if ((rf.refs = PyList_New(0)) != NULL) { in marshal_load()
1694 result = read_object(&rf); in marshal_load()
1695 Py_DECREF(rf.refs); in marshal_load()
1696 if (rf.buf != NULL) in marshal_load()
1697 PyMem_Free(rf.buf); in marshal_load()
1733 Convert the bytes-like object to a value.
1743 RFILE rf; in marshal_loads_impl() local
1744 char *s = bytes->buf; in marshal_loads_impl()
1745 Py_ssize_t n = bytes->len; in marshal_loads_impl()
1747 rf.fp = NULL; in marshal_loads_impl()
1748 rf.readable = NULL; in marshal_loads_impl()
1749 rf.ptr = s; in marshal_loads_impl()
1750 rf.end = s + n; in marshal_loads_impl()
1751 rf.depth = 0; in marshal_loads_impl()
1752 if ((rf.refs = PyList_New(0)) == NULL) in marshal_loads_impl()
1754 result = read_object(&rf); in marshal_loads_impl()
1755 Py_DECREF(rf.refs); in marshal_loads_impl()
1785 version -- indicates the format that the module uses. Version 0 is the\n\
1792 dump() -- write value to a file\n\
1793 load() -- read value from a file\n\
1794 dumps() -- marshal value as a bytes object\n\
1795 loads() -- read value from a bytes-like object");
1802 return -1; in marshal_module_exec()