Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
881928f7
Kaydet (Commit)
881928f7
authored
Mar 10, 1999
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch by Vladimir Marangoz to allow freeing of the allocated blocks of
floats on finalization.
üst
da084edd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
7 deletions
+56
-7
floatobject.c
Objects/floatobject.c
+56
-7
No files found.
Objects/floatobject.c
Dosyayı görüntüle @
881928f7
...
...
@@ -95,20 +95,27 @@ double (*_Py_math_funcs_hack[])() = {
/* Special free list -- see comments for same code in intobject.c. */
static
PyFloatObject
*
free_list
=
NULL
;
static
PyFloatObject
*
block_list
=
NULL
;
#define BLOCK_SIZE 1000
/* 1K less typical malloc overhead */
#define N_FLOATOBJECTS (BLOCK_SIZE / sizeof(PyFloatObject))
#define N_FLOATOBJECTS ((BLOCK_SIZE - sizeof(PyFloatObject *)) / \
sizeof(PyFloatObject))
#define PyMem_MALLOC malloc
#define PyMem_FREE free
static
PyFloatObject
*
fill_free_list
()
{
PyFloatObject
*
p
,
*
q
;
p
=
PyMem_NEW
(
PyFloatObject
,
N_FLOATOBJECTS
);
p
=
(
PyFloatObject
*
)
PyMem_MALLOC
(
BLOCK_SIZE
);
if
(
p
==
NULL
)
return
(
PyFloatObject
*
)
PyErr_NoMemory
();
*
(
PyFloatObject
**
)
p
=
block_list
;
block_list
=
p
;
p
=
(
PyFloatObject
*
)((
char
*
)
p
+
sizeof
(
PyFloatObject
*
));
q
=
p
+
N_FLOATOBJECTS
;
while
(
--
q
>
p
)
*
(
PyFloatObject
**
)
q
=
q
-
1
;
*
(
PyFloatObject
**
)
q
=
NULL
;
q
->
ob_type
=
(
struct
_typeobject
*
)(
q
-
1
)
;
q
->
ob_type
=
NULL
;
return
p
+
N_FLOATOBJECTS
-
1
;
}
...
...
@@ -126,7 +133,7 @@ PyFloat_FromDouble(fval)
return
NULL
;
}
op
=
free_list
;
free_list
=
*
(
PyFloatObject
**
)
free_list
;
free_list
=
(
PyFloatObject
*
)
op
->
ob_type
;
op
->
ob_type
=
&
PyFloat_Type
;
op
->
ob_fval
=
fval
;
_Py_NewReference
(
op
);
...
...
@@ -137,7 +144,7 @@ static void
float_dealloc
(
op
)
PyFloatObject
*
op
;
{
*
(
PyFloatObject
**
)
op
=
free_list
;
op
->
ob_type
=
(
struct
_typeobject
*
)
free_list
;
free_list
=
op
;
}
...
...
@@ -604,5 +611,47 @@ PyTypeObject PyFloat_Type = {
void
PyFloat_Fini
()
{
/* XXX Alas, the free list is not easily and safely freeable */
PyFloatObject
*
p
,
*
list
;
int
i
;
int
bc
,
bf
;
/* block count, number of freed blocks */
int
frem
,
fsum
;
/* remaining unfreed floats per block, total */
bc
=
0
;
bf
=
0
;
fsum
=
0
;
list
=
block_list
;
block_list
=
NULL
;
while
(
list
!=
NULL
)
{
p
=
list
;
p
=
(
PyFloatObject
*
)((
char
*
)
p
+
sizeof
(
PyFloatObject
*
));
bc
++
;
frem
=
0
;
for
(
i
=
0
;
i
<
N_FLOATOBJECTS
;
i
++
,
p
++
)
{
if
(
PyFloat_Check
(
p
)
&&
p
->
ob_refcnt
!=
0
)
frem
++
;
}
p
=
list
;
list
=
*
(
PyFloatObject
**
)
p
;
if
(
frem
)
{
*
(
PyFloatObject
**
)
p
=
block_list
;
block_list
=
p
;
}
else
{
PyMem_FREE
(
p
);
bf
++
;
}
fsum
+=
frem
;
}
if
(
Py_VerboseFlag
)
{
fprintf
(
stderr
,
"# cleanup floats"
);
if
(
!
fsum
)
{
fprintf
(
stderr
,
"
\n
"
);
}
else
{
fprintf
(
stderr
,
": %d unfreed float%s in %d out of %d block%s
\n
"
,
fsum
,
fsum
==
1
?
""
:
"s"
,
bc
-
bf
,
bc
,
bc
==
1
?
""
:
"s"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment