free when pop int and float

This commit is contained in:
lyon1998 2021-10-13 10:40:47 +08:00
parent dcddd8bbb5
commit 64111e1063
2 changed files with 13 additions and 9 deletions

View File

@ -13,7 +13,7 @@
"args": [
// "--gtest_filter=object_test.test2"
// "--gtest_filter=block.init"
"--gtest_filter=block.ifrun2"
// "--gtest_filter=block.ifrun2"
// "--gtest_filter=sysObj.print"
// "--gtest_filter=object_test.a_b"
// "--gtest_filter=object_test.voidRun"

View File

@ -27,7 +27,7 @@ int32_t queue_pushInt(Queue* queue, int val) {
Args* args = queue;
uint64_t top = args_getInt(args, "top");
char topStr[32] = {0};
sprintf(topStr, "%d", top);
sprintf(topStr, "%ld", top);
/* add top */
args_setInt(args, "top", top + 1);
return args_setInt(args, topStr, val);
@ -37,17 +37,19 @@ int64_t queue_popInt(Queue* queue) {
Args* args = queue;
uint64_t bottom = args_getInt(args, "bottom");
char bottomStr[32] = {0};
sprintf(bottomStr, "%d", bottom);
sprintf(bottomStr, "%ld", bottom);
/* add bottom */
args_setInt(args, "bottom", bottom + 1);
return args_getInt(args, bottomStr);
int64_t res = args_getInt(args, bottomStr);
args_removeArg(args, bottomStr);
return res;
}
int32_t queue_pushFloat(Queue* queue, float val) {
Args* args = queue;
uint64_t top = args_getInt(args, "top");
char topStr[32] = {0};
sprintf(topStr, "%d", top);
sprintf(topStr, "%ld", top);
/* add top */
args_setInt(args, "top", top + 1);
return args_setFloat(args, topStr, val);
@ -57,17 +59,19 @@ float queue_popFloat(Queue* queue) {
Args* args = queue;
uint64_t bottom = args_getInt(args, "bottom");
char bottomStr[32] = {0};
sprintf(bottomStr, "%d", bottom);
sprintf(bottomStr, "%ld", bottom);
/* add bottom */
args_setInt(args, "bottom", bottom + 1);
return args_getFloat(args, bottomStr);
float res = args_getFloat(args, bottomStr);
args_removeArg(args, bottomStr);
return res;
}
int32_t queue_pushStr(Queue* queue, char* str) {
Args* args = queue;
uint64_t top = args_getInt(args, "top");
char topStr[32] = {0};
sprintf(topStr, "%d", top);
sprintf(topStr, "%ld", top);
/* add top */
args_setInt(args, "top", top + 1);
return args_setStr(args, topStr, str);
@ -77,7 +81,7 @@ char* queue_popStr(Queue* queue) {
Args* args = queue;
uint64_t bottom = args_getInt(args, "bottom");
char bottomStr[32] = {0};
sprintf(bottomStr, "%d", bottom);
sprintf(bottomStr, "%ld", bottom);
/* add bottom */
args_setInt(args, "bottom", bottom + 1);
return args_getStr(args, bottomStr);