Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/cpython
Path: blob/main/Include/internal/pycore_bytesobject.h
12 views
1
#ifndef Py_INTERNAL_BYTESOBJECT_H
2
#define Py_INTERNAL_BYTESOBJECT_H
3
#ifdef __cplusplus
4
extern "C" {
5
#endif
6
7
#ifndef Py_BUILD_CORE
8
# error "this header requires Py_BUILD_CORE define"
9
#endif
10
11
12
/* Substring Search.
13
14
Returns the index of the first occurrence of
15
a substring ("needle") in a larger text ("haystack").
16
If the needle is not found, return -1.
17
If the needle is found, add offset to the index.
18
*/
19
20
PyAPI_FUNC(Py_ssize_t)
21
_PyBytes_Find(const char *haystack, Py_ssize_t len_haystack,
22
const char *needle, Py_ssize_t len_needle,
23
Py_ssize_t offset);
24
25
/* Same as above, but search right-to-left */
26
PyAPI_FUNC(Py_ssize_t)
27
_PyBytes_ReverseFind(const char *haystack, Py_ssize_t len_haystack,
28
const char *needle, Py_ssize_t len_needle,
29
Py_ssize_t offset);
30
31
32
/** Helper function to implement the repeat and inplace repeat methods on a buffer
33
*
34
* len_dest is assumed to be an integer multiple of len_src.
35
* If src equals dest, then assume the operation is inplace.
36
*
37
* This method repeately doubles the number of bytes copied to reduce
38
* the number of invocations of memcpy.
39
*/
40
PyAPI_FUNC(void)
41
_PyBytes_Repeat(char* dest, Py_ssize_t len_dest,
42
const char* src, Py_ssize_t len_src);
43
44
#ifdef __cplusplus
45
}
46
#endif
47
#endif /* !Py_INTERNAL_BYTESOBJECT_H */
48
49