Skip to content

Commit

Permalink
Enable debug mode and comment out memory clean up
Browse files Browse the repository at this point in the history
Debug mode is enabled in rayaop.c file to help with code troubleshooting. In addition, several lines of code that were responsible for releasing memory and setting variables to NULL have been temporarily commented out for further inspection and analysis.
  • Loading branch information
koriym committed Jul 2, 2024
1 parent 4cc434a commit b87e160
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions rayaop.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#endif

// デバッグ出力を有効にする場合はこのマクロをアンコメントしてください
// #define RAYAOP_DEBUG
#define RAYAOP_DEBUG

/**
* インターセプト情報を保持する構造体
Expand Down Expand Up @@ -196,16 +196,22 @@ static void efree_intercept_info(zval *zv)
intercept_info *info = Z_PTR_P(zv); // インターセプト情報を取得
if (info) {
RAYAOP_DEBUG_PRINT("Freeing intercept info for %s::%s", ZSTR_VAL(info->class_name), ZSTR_VAL(info->method_name));
RAYAOP_DEBUG_PRINT("Before zend_string_release: refcount = %d", info->class_name->gc.refcount);
RAYAOP_DEBUG_PRINT("Before zend_string_release: refcount = %d, len = %zu, val = %s",
info->class_name->gc.refcount,
info->class_name->len,
ZSTR_VAL(info->class_name));


// zend_string_release(info->class_name); // クラス名を解放
// zend_string_release(info->method_name); // メソッド名を解放

zend_string_release(info->class_name); // クラス名を解放
zend_string_release(info->method_name); // メソッド名を解放
RAYAOP_DEBUG_PRINT("class_name and method_name released");

zval_ptr_dtor(&info->handler); // ハンドラーを解放
RAYAOP_DEBUG_PRINT("handler released");

efree(info); // インターセプト情報構造体を解放
RAYAOP_DEBUG_PRINT("Memory freed for intercept info");
}
}

Expand Down Expand Up @@ -243,8 +249,8 @@ PHP_MSHUTDOWN_FUNCTION(rayaop)

if (intercept_ht) {
// zend_hash_destroy(intercept_ht); // ハッシュテーブルを破棄
pefree(intercept_ht, 0); // ハッシュテーブルのメモリを解放
intercept_ht = NULL; // ハッシュテーブルポインタをNULLに設定
// pefree(intercept_ht, 0); // ハッシュテーブルのメモリを解放
// intercept_ht = NULL; // ハッシュテーブルポインタをNULLに設定
}

RAYAOP_DEBUG_PRINT("RayAOP extension shut down");
Expand Down

0 comments on commit b87e160

Please sign in to comment.