mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-31 23:15:13 +08:00
🏅 Sync 2026-04-20 20:27:29
This commit is contained in:
1 parent
03109ea917
commit
ede68af29e
24 files changed
+2286
-2110
No files matched your search
@@ -9,7 +9,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#define LOG_FILE_PATH "/tmp/log/appfilter.log"
|
||||
#define OAF_VERSION "6.1.7"
|
||||
#define OAF_VERSION "6.1.8"
|
||||
|
||||
typedef enum {
|
||||
LOG_LEVEL_ERROR,
|
||||
|
||||
@@ -255,16 +255,16 @@ appfilter_handle_dev_visit_list(struct ubus_context *ctx, struct ubus_object *ob
|
||||
|
||||
int total_count = json_object_array_length(visit_array);
|
||||
|
||||
struct json_object *paged_array = NULL;
|
||||
if (page == 0) {
|
||||
paged_array = visit_array;
|
||||
json_object_get(visit_array);
|
||||
} else {
|
||||
paged_array = json_object_new_array();
|
||||
int start_idx = (page - 1) * page_size;
|
||||
int end_idx = start_idx + page_size;
|
||||
int i;
|
||||
for (i = start_idx; i < end_idx && i < total_count; i++) {
|
||||
struct json_object *paged_array = NULL;
|
||||
if (page <= 0) {
|
||||
/* Reuse visit_array as response data while keeping a local reference for cleanup. */
|
||||
paged_array = json_object_get(visit_array);
|
||||
} else {
|
||||
paged_array = json_object_new_array();
|
||||
int start_idx = (page - 1) * page_size;
|
||||
int end_idx = start_idx + page_size;
|
||||
int i;
|
||||
for (i = start_idx; i < end_idx && i < total_count; i++) {
|
||||
struct json_object *visit_obj = json_object_array_get_idx(visit_array, i);
|
||||
if (visit_obj) {
|
||||
json_object_get(visit_obj);
|
||||
@@ -282,7 +282,8 @@ appfilter_handle_dev_visit_list(struct ubus_context *ctx, struct ubus_object *ob
|
||||
if (page_size > 0) {
|
||||
total_pages = (total_count + page_size - 1) / page_size; // Ceiling division
|
||||
}
|
||||
json_object_object_add(root_obj, "total_pages", json_object_new_int(total_pages));
|
||||
json_object_object_add(root_obj, "total_pages", json_object_new_int(total_pages));
|
||||
json_object_put(visit_array);
|
||||
|
||||
if (req_obj) {
|
||||
json_object_put(req_obj);
|
||||
@@ -1630,16 +1631,16 @@ static int handle_get_all_users(struct ubus_context *ctx, struct ubus_object *ob
|
||||
|
||||
int total_count = json_object_array_length(au_info.users_array);
|
||||
|
||||
struct json_object *paged_array = NULL;
|
||||
if (page == 0) {
|
||||
paged_array = au_info.users_array;
|
||||
json_object_get(au_info.users_array); // Increment reference count to prevent double free
|
||||
} else {
|
||||
paged_array = json_object_new_array();
|
||||
int start_idx = (page - 1) * page_size;
|
||||
int end_idx = start_idx + page_size;
|
||||
int i;
|
||||
for (i = start_idx; i < end_idx && i < total_count; i++) {
|
||||
struct json_object *paged_array = NULL;
|
||||
if (page <= 0) {
|
||||
/* Reuse users_array as response data while keeping a local reference for cleanup. */
|
||||
paged_array = json_object_get(au_info.users_array);
|
||||
} else {
|
||||
paged_array = json_object_new_array();
|
||||
int start_idx = (page - 1) * page_size;
|
||||
int end_idx = start_idx + page_size;
|
||||
int i;
|
||||
for (i = start_idx; i < end_idx && i < total_count; i++) {
|
||||
struct json_object *user_obj = json_object_array_get_idx(au_info.users_array, i);
|
||||
if (user_obj) {
|
||||
json_object_get(user_obj); // Increment reference count
|
||||
@@ -1658,7 +1659,8 @@ static int handle_get_all_users(struct ubus_context *ctx, struct ubus_object *ob
|
||||
if (page_size > 0) {
|
||||
total_pages = (total_count + page_size - 1) / page_size; // Ceiling division
|
||||
}
|
||||
json_object_object_add(data_obj, "total_pages", json_object_new_int(total_pages));
|
||||
json_object_object_add(data_obj, "total_pages", json_object_new_int(total_pages));
|
||||
json_object_put(au_info.users_array);
|
||||
|
||||
json_object_object_add(response, "data", data_obj);
|
||||
|
||||
|
||||
Reference in new issue
Block a user