Permalink
Browse files

Move APC_STRINGS to separate file

  • Loading branch information...
nikic committed Oct 21, 2018
1 parent 8766c26 commit 5c62fba1372671eb024fb76a42cf73d2824bf1e8
Showing with 56 additions and 28 deletions.
  1. +1 −28 apc_iterator.c
  2. +40 −0 apc_strings.h
  3. +15 −0 php_apc.c
@@ -20,32 +20,15 @@
#include "php_apc.h"
#include "apc_iterator.h"
#include "apc_cache.h"
#include "apc_strings.h"
#include "ext/standard/md5.h"
#include "SAPI.h"
#include "zend_interfaces.h"
#define APC_STRINGS \
X(user) \
X(type) \
X(key) \
X(value) \
X(num_hits) \
X(mtime) \
X(creation_time) \
X(deletion_time) \
X(access_time) \
X(ref_count) \
X(mem_size) \
X(ttl)
static zend_class_entry *apc_iterator_ce;
zend_object_handlers apc_iterator_object_handlers;
#define X(str) static zend_string *apc_str_ ## str;
APC_STRINGS
#undef X
zend_class_entry* apc_iterator_get_ce(void) {
return apc_iterator_ce;
}
@@ -628,21 +611,11 @@ int apc_iterator_init(int module_number) {
apc_iterator_object_handlers.free_obj = apc_iterator_free;
apc_iterator_object_handlers.offset = XtOffsetOf(apc_iterator_t, obj);
#define X(str) \
apc_str_ ## str = zend_new_interned_string( \
zend_string_init(#str, sizeof(#str) - 1, 1));
APC_STRINGS
#undef X
return SUCCESS;
}
/* }}} */
int apc_iterator_shutdown(int module_number) {
#define X(str) zend_string_release(apc_str_ ## str);
APC_STRINGS
#undef X
return SUCCESS;
}
@@ -0,0 +1,40 @@
/*
+----------------------------------------------------------------------+
| APC |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Nikita Popov <nikic@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef APC_STRINGS_H
#define APC_STRINGS_H
#define APC_STRINGS \
X(user) \
X(type) \
X(key) \
X(value) \
X(num_hits) \
X(mtime) \
X(creation_time) \
X(deletion_time) \
X(access_time) \
X(ref_count) \
X(mem_size) \
X(ttl)
#define X(str) extern zend_string *apc_str_ ## str;
APC_STRINGS
#undef X
#endif
@@ -34,6 +34,7 @@
#include "apc_iterator.h"
#include "apc_sma.h"
#include "apc_lock.h"
#include "apc_strings.h"
#include "php_globals.h"
#include "php_ini.h"
#include "ext/standard/info.h"
@@ -78,6 +79,10 @@ apc_cache_t* apc_user_cache = NULL;
/* External APC SMA */
apc_sma_t apc_sma;
#define X(str) zend_string *apc_str_ ## str;
APC_STRINGS
#undef X
/* Global init functions */
static void php_apc_init_globals(zend_apcu_globals* apcu_globals)
{
@@ -214,6 +219,12 @@ static PHP_MINIT_FUNCTION(apcu)
REGISTER_INI_ENTRIES();
#define X(str) \
apc_str_ ## str = zend_new_interned_string( \
zend_string_init(#str, sizeof(#str) - 1, 1));
APC_STRINGS
#undef X
/* locks initialized regardless of settings */
apc_lock_init();
@@ -273,6 +284,10 @@ static PHP_MINIT_FUNCTION(apcu)
/* {{{ PHP_MSHUTDOWN_FUNCTION(apcu) */
static PHP_MSHUTDOWN_FUNCTION(apcu)
{
#define X(str) zend_string_release(apc_str_ ## str);
APC_STRINGS
#undef X
/* locks shutdown regardless of settings */
apc_lock_cleanup();

0 comments on commit 5c62fba

Please sign in to comment.