mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
support deinit no ref object
This commit is contained in:
parent
4956994086
commit
ba11251d6d
@ -342,18 +342,15 @@ void* arg_getHeapStruct(Arg* self) {
|
||||
}
|
||||
|
||||
void arg_deinitHeap(Arg* self) {
|
||||
if (arg_getType(self) == ARG_TYPE_HEAP_STRUCT) {
|
||||
ArgType type = arg_getType(self);
|
||||
/* deinit heap struct */
|
||||
if (type == ARG_TYPE_HEAP_STRUCT) {
|
||||
/* deinit heap strcut */
|
||||
StructDeinitFun struct_deinit_fun =
|
||||
(StructDeinitFun)arg_getHeapStructDeinitFun(self);
|
||||
struct_deinit_fun(arg_getHeapStruct(self));
|
||||
}
|
||||
}
|
||||
|
||||
void arg_deinit(Arg* self) {
|
||||
arg_deinitHeap(self);
|
||||
/* deinit sub object */
|
||||
ArgType type = arg_getType(self);
|
||||
if (type == ARG_TYPE_OBJECT) {
|
||||
PikaObj* subObj = arg_getPtr(self);
|
||||
obj_refcntDec(subObj);
|
||||
@ -362,6 +359,11 @@ void arg_deinit(Arg* self) {
|
||||
obj_deinit(subObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void arg_deinit(Arg* self) {
|
||||
/* deinit arg pointed heap */
|
||||
arg_deinitHeap(self);
|
||||
/* free the ref */
|
||||
arg_freeContent(self);
|
||||
}
|
||||
|
@ -721,25 +721,25 @@ TEST(pikaMain, string_no_init_arg) {
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
// TEST(pikaMain, obj_no_free) {
|
||||
// /* init */
|
||||
// pikaMemInfo.heapUsedMax = 0;
|
||||
// PikaObj* pikaMain = newRootObj((char*)"pikaMain", New_PikaMain);
|
||||
// /* run */
|
||||
// __platform_printf((char*)"BEGIN\n");
|
||||
// obj_run(pikaMain, (char*)
|
||||
// "s = PikaStdData.String()\n"
|
||||
// "s.set('test')\n"
|
||||
// "s = PikaStdData.String()\n"
|
||||
// "s.set('test')\n"
|
||||
// "\n"
|
||||
// );
|
||||
// /* collect */
|
||||
// /* assert */
|
||||
// /* deinit */
|
||||
// obj_deinit(pikaMain);
|
||||
// EXPECT_EQ(pikaMemNow(), 0);
|
||||
// }
|
||||
TEST(pikaMain, obj_no_free) {
|
||||
/* init */
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj((char*)"pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf((char*)"BEGIN\n");
|
||||
obj_run(pikaMain, (char*)
|
||||
"s = PikaStdData.String()\n"
|
||||
"s.set('test')\n"
|
||||
"s = PikaStdData.String()\n"
|
||||
"s.set('test')\n"
|
||||
"\n"
|
||||
);
|
||||
/* collect */
|
||||
/* assert */
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(pikaMain, list__set__) {
|
||||
/* init */
|
||||
|
@ -342,18 +342,15 @@ void* arg_getHeapStruct(Arg* self) {
|
||||
}
|
||||
|
||||
void arg_deinitHeap(Arg* self) {
|
||||
if (arg_getType(self) == ARG_TYPE_HEAP_STRUCT) {
|
||||
ArgType type = arg_getType(self);
|
||||
/* deinit heap struct */
|
||||
if (type == ARG_TYPE_HEAP_STRUCT) {
|
||||
/* deinit heap strcut */
|
||||
StructDeinitFun struct_deinit_fun =
|
||||
(StructDeinitFun)arg_getHeapStructDeinitFun(self);
|
||||
struct_deinit_fun(arg_getHeapStruct(self));
|
||||
}
|
||||
}
|
||||
|
||||
void arg_deinit(Arg* self) {
|
||||
arg_deinitHeap(self);
|
||||
/* deinit sub object */
|
||||
ArgType type = arg_getType(self);
|
||||
if (type == ARG_TYPE_OBJECT) {
|
||||
PikaObj* subObj = arg_getPtr(self);
|
||||
obj_refcntDec(subObj);
|
||||
@ -362,6 +359,11 @@ void arg_deinit(Arg* self) {
|
||||
obj_deinit(subObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void arg_deinit(Arg* self) {
|
||||
/* deinit arg pointed heap */
|
||||
arg_deinitHeap(self);
|
||||
/* free the ref */
|
||||
arg_freeContent(self);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user