This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
193 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "Python.h" | ||
#include "asdl.h" | ||
|
||
asdl_seq * | ||
_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena) | ||
{ | ||
asdl_seq *seq = NULL; | ||
size_t n; | ||
|
||
/* check size is sane */ | ||
if (size < 0 || | ||
(size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) { | ||
PyErr_NoMemory(); | ||
return NULL; | ||
} | ||
n = (size ? (sizeof(void *) * (size - 1)) : 0); | ||
|
||
/* check if size can be added safely */ | ||
if (n > PY_SIZE_MAX - sizeof(asdl_seq)) { | ||
PyErr_NoMemory(); | ||
return NULL; | ||
} | ||
n += sizeof(asdl_seq); | ||
|
||
seq = (asdl_seq *)PyArena_Malloc(arena, n); | ||
if (!seq) { | ||
PyErr_NoMemory(); | ||
return NULL; | ||
} | ||
memset(seq, 0, n); | ||
seq->size = size; | ||
return seq; | ||
} | ||
|
||
asdl_int_seq * | ||
_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena) | ||
{ | ||
asdl_int_seq *seq = NULL; | ||
size_t n; | ||
|
||
/* check size is sane */ | ||
if (size < 0 || | ||
(size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) { | ||
PyErr_NoMemory(); | ||
return NULL; | ||
} | ||
n = (size ? (sizeof(void *) * (size - 1)) : 0); | ||
|
||
/* check if size can be added safely */ | ||
if (n > PY_SIZE_MAX - sizeof(asdl_seq)) { | ||
PyErr_NoMemory(); | ||
return NULL; | ||
} | ||
n += sizeof(asdl_seq); | ||
|
||
seq = (asdl_int_seq *)PyArena_Malloc(arena, n); | ||
if (!seq) { | ||
PyErr_NoMemory(); | ||
return NULL; | ||
} | ||
memset(seq, 0, n); | ||
seq->size = size; | ||
return seq; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.