Mercurial > cpython-lru_cache-weakref
annotate Python/memmove.c @ 41769:b29d71d43c80
Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
PyString_Concat() and PyString_ConcatAndDel() (the name PyUnicode_Concat()
was already taken).
Change PyObject_Repr() to always return a unicode object.
Update all repr implementations to return unicode objects.
Add a function PyObject_ReprStr8() that calls PyObject_Repr() and converts
the result to an 8bit string.
Use PyObject_ReprStr8() where using PyObject_Repr() can't be done
straightforward.
| author | Walter Dörwald <walter@livinglogic.de> |
|---|---|
| date | Fri, 18 May 2007 17:15:44 +0000 |
| parents | 6f6f965c5e2d |
| children |
| rev | line source |
|---|---|
| 1449 | 1 |
| 2 /* A perhaps slow but I hope correct implementation of memmove */ | |
| 3 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13256
diff
changeset
|
4 extern char *memcpy(char *, char *, int); |
| 1449 | 5 |
| 6 char * | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13256
diff
changeset
|
7 memmove(char *dst, char *src, int n) |
| 1449 | 8 { |
| 9 char *realdst = dst; | |
| 10 if (n <= 0) | |
| 11 return dst; | |
| 12 if (src >= dst+n || dst >= src+n) | |
| 13 return memcpy(dst, src, n); | |
| 14 if (src > dst) { | |
| 15 while (--n >= 0) | |
| 16 *dst++ = *src++; | |
| 17 } | |
| 18 else if (src < dst) { | |
| 19 src += n; | |
| 20 dst += n; | |
| 21 while (--n >= 0) | |
| 22 *--dst = *--src; | |
| 23 } | |
| 24 return realdst; | |
| 25 } |
