libmbfl/mbfl/mbfl_language.c
libmbfl/mbfl/mbfl_memory_device.c
libmbfl/mbfl/mbfl_string.c
- libmbfl/mbfl/mbfl_allocators.c
libmbfl/nls/nls_de.c
libmbfl/nls/nls_en.c
libmbfl/nls/nls_ja.c
libmbfl/nls/nls_ua.c
])
PHP_MBSTRING_ADD_CFLAG([-DHAVE_CONFIG_H])
- PHP_MBSTRING_ADD_INSTALL_HEADERS([libmbfl/config.h libmbfl/mbfl/eaw_table.h libmbfl/mbfl/mbfilter.h libmbfl/mbfl/mbfilter_8bit.h libmbfl/mbfl/mbfilter_pass.h libmbfl/mbfl/mbfilter_wchar.h libmbfl/mbfl/mbfl_allocators.h libmbfl/mbfl/mbfl_consts.h libmbfl/mbfl/mbfl_convert.h libmbfl/mbfl/mbfl_defs.h libmbfl/mbfl/mbfl_encoding.h libmbfl/mbfl/mbfl_filter_output.h libmbfl/mbfl/mbfl_ident.h libmbfl/mbfl/mbfl_language.h libmbfl/mbfl/mbfl_memory_device.h libmbfl/mbfl/mbfl_string.h])
+ PHP_MBSTRING_ADD_INSTALL_HEADERS([libmbfl/config.h libmbfl/mbfl/eaw_table.h libmbfl/mbfl/mbfilter.h libmbfl/mbfl/mbfilter_8bit.h libmbfl/mbfl/mbfilter_pass.h libmbfl/mbfl/mbfilter_wchar.h libmbfl/mbfl/mbfl_consts.h libmbfl/mbfl/mbfl_convert.h libmbfl/mbfl/mbfl_defs.h libmbfl/mbfl/mbfl_encoding.h libmbfl/mbfl/mbfl_filter_output.h libmbfl/mbfl/mbfl_ident.h libmbfl/mbfl/mbfl_language.h libmbfl/mbfl/mbfl_memory_device.h libmbfl/mbfl/mbfl_string.h])
])
dnl
ADD_SOURCES("ext/mbstring/libmbfl/mbfl", "mbfilter.c mbfilter_8bit.c \
mbfilter_pass.c mbfilter_wchar.c mbfl_convert.c mbfl_encoding.c \
mbfl_filter_output.c mbfl_ident.c mbfl_language.c mbfl_memory_device.c \
- mbfl_string.c mbfl_allocators.c", "mbstring");
+ mbfl_string.c", "mbstring");
ADD_SOURCES("ext/mbstring/libmbfl/nls", "nls_de.c nls_en.c nls_ja.c \
nls_kr.c nls_neutral.c nls_ru.c nls_uni.c nls_zh.c nls_hy.c \
nls_ua.c nls_tr.c", "mbstring");
- PHP_INSTALL_HEADERS("ext/mbstring", "mbstring.h libmbfl/config.h libmbfl/mbfl/eaw_table.h libmbfl/mbfl/mbfilter.h libmbfl/mbfl/mbfilter_8bit.h libmbfl/mbfl/mbfilter_pass.h libmbfl/mbfl/mbfilter_wchar.h libmbfl/mbfl/mbfl_allocators.h libmbfl/mbfl/mbfl_consts.h libmbfl/mbfl/mbfl_convert.h libmbfl/mbfl/mbfl_defs.h libmbfl/mbfl/mbfl_encoding.h libmbfl/mbfl/mbfl_filter_output.h libmbfl/mbfl/mbfl_ident.h libmbfl/mbfl/mbfl_language.h libmbfl/mbfl/mbfl_memory_device.h libmbfl/mbfl/mbfl_string.h");
+ PHP_INSTALL_HEADERS("ext/mbstring", "mbstring.h libmbfl/config.h libmbfl/mbfl/eaw_table.h libmbfl/mbfl/mbfilter.h libmbfl/mbfl/mbfilter_8bit.h libmbfl/mbfl/mbfilter_pass.h libmbfl/mbfl/mbfilter_wchar.h libmbfl/mbfl/mbfl_consts.h libmbfl/mbfl/mbfl_convert.h libmbfl/mbfl/mbfl_defs.h libmbfl/mbfl/mbfl_encoding.h libmbfl/mbfl/mbfl_filter_output.h libmbfl/mbfl/mbfl_ident.h libmbfl/mbfl/mbfl_language.h libmbfl/mbfl/mbfl_memory_device.h libmbfl/mbfl/mbfl_string.h");
AC_DEFINE('HAVE_MBSTRING', 1, 'Have mbstring support');
mbfl_filt_conv_common_ctor(filt);
- ctx = mbfl_malloc(sizeof(mbfl_filt_conv_wchar_cp50220_ctx));
+ ctx = emalloc(sizeof(mbfl_filt_conv_wchar_cp50220_ctx));
ctx->tl_param.mode = MBFL_FILT_TL_HAN2ZEN_KATAKANA | MBFL_FILT_TL_HAN2ZEN_GLUE;
ctx->last = *filt;
mbfl_filt_conv_wchar_cp50220_ctx *ctx;
*dest = *src;
- ctx = mbfl_malloc(sizeof(mbfl_filt_conv_wchar_cp50220_ctx));
+ ctx = emalloc(sizeof(mbfl_filt_conv_wchar_cp50220_ctx));
dest->opaque = ctx;
dest->data = &ctx->last;
}
vtbl_tl_jisx0201_jisx0208.filter_dtor(filt);
if (filt->opaque != NULL) {
- mbfl_free(filt->opaque);
+ efree(filt->opaque);
}
mbfl_filt_conv_common_dtor(filt);
void mbfl_filt_conv_html_dec_ctor(mbfl_convert_filter *filter)
{
filter->status = 0;
- filter->opaque = mbfl_malloc(html_enc_buffer_size+1);
+ filter->opaque = emalloc(html_enc_buffer_size+1);
}
void mbfl_filt_conv_html_dec_dtor(mbfl_convert_filter *filter)
filter->status = 0;
if (filter->opaque)
{
- mbfl_free((void*)filter->opaque);
+ efree((void*)filter->opaque);
}
filter->opaque = NULL;
}
void mbfl_filt_conv_html_dec_copy(mbfl_convert_filter *src, mbfl_convert_filter *dest)
{
*dest = *src;
- dest->opaque = mbfl_malloc(html_enc_buffer_size+1);
+ dest->opaque = emalloc(html_enc_buffer_size+1);
memcpy(dest->opaque, src->opaque, html_enc_buffer_size+1);
}
*
*/
-#include "mbfl_allocators.h"
#include "mbfilter_tl_jisx0201_jisx0208.h"
#include "translit_kana_jisx0201_jisx0208.h"
const mbfl_encoding *to,
size_t buf_initsz)
{
- mbfl_buffer_converter *convd = mbfl_malloc(sizeof(mbfl_buffer_converter));
+ mbfl_buffer_converter *convd = emalloc(sizeof(mbfl_buffer_converter));
convd->from = from;
convd->to = to;
}
}
if (convd->filter1 == NULL) {
- mbfl_free(convd);
+ efree(convd);
return NULL;
}
mbfl_convert_filter_delete(convd->filter2);
}
mbfl_memory_device_clear(&convd->device);
- mbfl_free((void*)convd);
+ efree((void*)convd);
}
}
}
/* allocate */
- identd = mbfl_malloc(sizeof(mbfl_encoding_detector));
- identd->filter_list = mbfl_calloc(elistsz, sizeof(mbfl_identify_filter *));
+ identd = emalloc(sizeof(mbfl_encoding_detector));
+ identd->filter_list = ecalloc(elistsz, sizeof(mbfl_identify_filter *));
/* create filters */
i = 0;
i--;
mbfl_identify_filter_delete(identd->filter_list[i]);
}
- mbfl_free((void *)identd->filter_list);
+ efree((void *)identd->filter_list);
}
- mbfl_free((void *)identd);
+ efree((void *)identd);
}
}
const mbfl_encoding *encoding;
/* flist is an array of mbfl_identify_filter instances */
- flist = mbfl_calloc(elistsz, sizeof(mbfl_identify_filter));
+ flist = ecalloc(elistsz, sizeof(mbfl_identify_filter));
num = 0;
if (elist != NULL) {
mbfl_identify_filter_cleanup(&flist[i]);
}
- mbfl_free((void *)flist);
+ efree((void *)flist);
return encoding;
}
/* allocate memory and copy */
n = end - start;
result->len = 0;
- result->val = w = (unsigned char*)mbfl_malloc(n + 1);
+ result->val = w = (unsigned char*)emalloc(n + 1);
result->len = n;
memcpy(w, string->val + start, n);
w[n] = '\0';
/* allocate memory and copy string */
sz = end - start;
- w = mbfl_calloc(sz + 8, sizeof(unsigned char));
+ w = ecalloc(sz + 8, sizeof(unsigned char));
memcpy(w, start, sz);
w[sz] = '\0';
}
next_filter = decoder;
- param = mbfl_malloc(sizeof(mbfl_filt_tl_jisx0201_jisx0208_param));
+ param = emalloc(sizeof(mbfl_filt_tl_jisx0201_jisx0208_param));
param->mode = mode;
tl_filter = mbfl_convert_filter_new2(
(int(*)(void*))next_filter->filter_flush,
next_filter);
if (tl_filter == NULL) {
- mbfl_free(param);
+ efree(param);
goto out;
}
out:
if (tl_filter != NULL) {
if (tl_filter->opaque != NULL) {
- mbfl_free(tl_filter->opaque);
+ efree(tl_filter->opaque);
}
mbfl_convert_filter_delete(tl_filter);
}
return NULL;
}
- pe = mbfl_malloc(sizeof(struct mime_header_encoder_data));
+ pe = emalloc(sizeof(struct mime_header_encoder_data));
mbfl_memory_device_init(&pe->outdev, 0, 0);
mbfl_memory_device_init(&pe->tmpdev, 0, 0);
pe->prevpos = 0;
mbfl_convert_filter_delete(pe->encod_filter_backup);
mbfl_memory_device_clear(&pe->outdev);
mbfl_memory_device_clear(&pe->tmpdev);
- mbfl_free((void*)pe);
+ efree((void*)pe);
}
}
struct mime_header_decoder_data*
mime_header_decoder_new(const mbfl_encoding *outcode)
{
- struct mime_header_decoder_data *pd = mbfl_malloc(sizeof(struct mime_header_decoder_data));
+ struct mime_header_decoder_data *pd = emalloc(sizeof(struct mime_header_decoder_data));
mbfl_memory_device_init(&pd->outdev, 0, 0);
mbfl_memory_device_init(&pd->tmpdev, 0, 0);
mbfl_convert_filter_delete(pd->deco_filter);
mbfl_memory_device_clear(&pd->outdev);
mbfl_memory_device_clear(&pd->tmpdev);
- mbfl_free((void*)pd);
+ efree((void*)pd);
}
}
#ifndef MBFL_MBFILTER_H
#define MBFL_MBFILTER_H
+#include "zend.h"
+
#include "mbfl_defs.h"
#include "mbfl_consts.h"
-#include "mbfl_allocators.h"
#include "mbfl_encoding.h"
#include "mbfl_language.h"
#include "mbfl_string.h"
+++ /dev/null
-/*
- * "streamable kanji code filter and converter"
- * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
- *
- * LICENSE NOTICES
- *
- * This file is part of "streamable kanji code filter and converter",
- * which is distributed under the terms of GNU Lesser General Public
- * License (version 2) as published by the Free Software Foundation.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with "streamable kanji code filter and converter";
- * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- *
- * The author of this file:
- *
- */
-/*
- * The source code included in this files was separated from mbfilter.c
- * by Moriyoshi Koizumi <moriyoshi@php.net> on 20 Dec 2002. The file
- * mbfilter.c is included in this package .
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <stddef.h>
-
-#include "mbfl_allocators.h"
-
-static void *__mbfl__malloc(size_t);
-static void *__mbfl__realloc(void *, size_t);
-static void *__mbfl__calloc(size_t, size_t);
-static void __mbfl__free(void *);
-
-static mbfl_allocators default_allocators = {
- __mbfl__malloc,
- __mbfl__realloc,
- __mbfl__calloc,
- __mbfl__free,
-};
-
-mbfl_allocators *__mbfl_allocators = &default_allocators;
-
-static void *__mbfl__malloc(size_t sz)
-{
- return malloc(sz);
-}
-
-static void *__mbfl__realloc(void *ptr, size_t sz)
-{
- return realloc(ptr, sz);
-}
-
-static void *__mbfl__calloc(size_t nelems, size_t szelem)
-{
- return calloc(nelems, szelem);
-}
-
-static void __mbfl__free(void *ptr)
-{
- free(ptr);
-}
+++ /dev/null
-/*
- * "streamable kanji code filter and converter"
- * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
- *
- * LICENSE NOTICES
- *
- * This file is part of "streamable kanji code filter and converter",
- * which is distributed under the terms of GNU Lesser General Public
- * License (version 2) as published by the Free Software Foundation.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with "streamable kanji code filter and converter";
- * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- *
- * The author of this file:
- *
- */
-/*
- * The source code included in this files was separated from mbfilter.h
- * by Moriyoshi Koizumi <moriyoshi@php.net> on 20 Dec 2002. The file
- * mbfilter.h is included in this package .
- *
- */
-
-#ifndef MBFL_ALLOCATORS_H
-#define MBFL_ALLOCATORS_H
-
-#include <stddef.h>
-#include "mbfl_defs.h"
-
-/* All allocation functions are required to be infallible.
- * That is, they must never return NULL. */
-
-typedef struct _mbfl_allocators {
- void *(*malloc)(size_t);
- void *(*realloc)(void *, size_t);
- void *(*calloc)(size_t, size_t);
- void (*free)(void *);
-} mbfl_allocators;
-
-MBFLAPI extern mbfl_allocators *__mbfl_allocators;
-
-#define mbfl_malloc (__mbfl_allocators->malloc)
-#define mbfl_realloc (__mbfl_allocators->realloc)
-#define mbfl_calloc (__mbfl_allocators->calloc)
-#define mbfl_free (__mbfl_allocators->free)
-
-#endif /* MBFL_ALLOCATORS_H */
#include <stddef.h>
#include "mbfl_encoding.h"
-#include "mbfl_allocators.h"
#include "mbfl_filter_output.h"
#include "mbfilter_pass.h"
#include "mbfilter_8bit.h"
return NULL;
}
- filter = mbfl_malloc(sizeof(mbfl_convert_filter));
+ filter = emalloc(sizeof(mbfl_convert_filter));
if (mbfl_convert_filter_common_init(filter, from, to, vtbl,
output_function, flush_function, data)) {
- mbfl_free(filter);
+ efree(filter);
return NULL;
}
from_encoding = mbfl_no2encoding(vtbl->from);
to_encoding = mbfl_no2encoding(vtbl->to);
- filter = mbfl_malloc(sizeof(mbfl_convert_filter));
+ filter = emalloc(sizeof(mbfl_convert_filter));
if (mbfl_convert_filter_common_init(filter, from_encoding, to_encoding, vtbl,
output_function, flush_function, data)) {
- mbfl_free(filter);
+ efree(filter);
return NULL;
}
{
if (filter) {
(*filter->filter_dtor)(filter);
- mbfl_free((void*)filter);
+ efree((void*)filter);
}
}
#include <stddef.h>
#include "mbfl_ident.h"
-#include "mbfl_allocators.h"
#include "mbfilter_pass.h"
#include "mbfilter_8bit.h"
#include "mbfilter_wchar.h"
mbfl_identify_filter *mbfl_identify_filter_new(enum mbfl_no_encoding encoding)
{
- mbfl_identify_filter *filter = mbfl_malloc(sizeof(mbfl_identify_filter));
+ mbfl_identify_filter *filter = emalloc(sizeof(mbfl_identify_filter));
if (mbfl_identify_filter_init(filter, encoding)) {
- mbfl_free(filter);
+ efree(filter);
return NULL;
}
mbfl_identify_filter *mbfl_identify_filter_new2(const mbfl_encoding *encoding)
{
- mbfl_identify_filter *filter = mbfl_malloc(sizeof(mbfl_identify_filter));
+ mbfl_identify_filter *filter = emalloc(sizeof(mbfl_identify_filter));
if (mbfl_identify_filter_init2(filter, encoding)) {
- mbfl_free(filter);
+ efree(filter);
return NULL;
}
}
mbfl_identify_filter_cleanup(filter);
- mbfl_free((void*)filter);
+ efree((void*)filter);
}
void mbfl_identify_filter_cleanup(mbfl_identify_filter *filter)
#endif
#include <stddef.h>
-
#include <string.h>
-#include "mbfl_allocators.h"
+
+#include "zend.h"
#include "mbfl_string.h"
#include "mbfl_memory_device.h"
device->length = 0;
device->buffer = NULL;
if (initsz > 0) {
- device->buffer = mbfl_malloc(initsz);
+ device->buffer = emalloc(initsz);
device->length = initsz;
}
device->pos = 0;
{
if (device) {
if (initsz > device->length) {
- device->buffer = mbfl_realloc(device->buffer, initsz);
+ device->buffer = erealloc(device->buffer, initsz);
device->length = initsz;
}
if (allocsz > MBFL_MEMORY_DEVICE_ALLOC_SIZE) {
{
if (device) {
if (device->buffer) {
- mbfl_free(device->buffer);
+ efree(device->buffer);
}
device->buffer = NULL;
device->length = 0;
}
newlen = device->length + device->allocsz;
- device->buffer = mbfl_realloc(device->buffer, newlen);
+ device->buffer = erealloc(device->buffer, newlen);
device->length = newlen;
}
}
newlen = device->length + device->allocsz;
- device->buffer = mbfl_realloc(device->buffer, newlen);
+ device->buffer = erealloc(device->buffer, newlen);
device->length = newlen;
}
}
newlen = device->length + device->allocsz;
- device->buffer = mbfl_realloc(device->buffer, newlen);
+ device->buffer = erealloc(device->buffer, newlen);
device->length = newlen;
}
}
newlen = device->length + len + MBFL_MEMORY_DEVICE_ALLOC_SIZE;
- device->buffer = mbfl_realloc(device->buffer, newlen);
+ device->buffer = erealloc(device->buffer, newlen);
device->length = newlen;
}
{
if (device) {
if (device->buffer) {
- mbfl_free(device->buffer);
+ efree(device->buffer);
}
device->buffer = NULL;
device->length = 0;
return -1;
}
- device->buffer = mbfl_realloc(device->buffer, newlen*sizeof(int));
+ device->buffer = erealloc(device->buffer, newlen*sizeof(int));
device->length = newlen;
}
#include <stddef.h>
-#include "mbfl_allocators.h"
#include "mbfl_string.h"
#include "mbfilter_pass.h"
mbfl_string_clear(mbfl_string *string)
{
if (string->val != (unsigned char*)NULL) {
- mbfl_free(string->val);
+ efree(string->val);
}
string->val = (unsigned char*)NULL;
string->len = 0;
#include "main/php_output.h"
#include "ext/standard/info.h"
-#include "libmbfl/mbfl/mbfl_allocators.h"
#include "libmbfl/mbfl/mbfilter_8bit.h"
#include "libmbfl/mbfl/mbfilter_pass.h"
#include "libmbfl/mbfl/mbfilter_wchar.h"
ZEND_GET_MODULE(mbstring)
#endif
-/* {{{ allocators */
-static void *_php_mb_allocators_malloc(size_t sz)
-{
- return emalloc(sz);
-}
-
-static void *_php_mb_allocators_realloc(void *ptr, size_t sz)
-{
- return erealloc(ptr, sz);
-}
-
-static void *_php_mb_allocators_calloc(size_t nelems, size_t szelem)
-{
- return ecalloc(nelems, szelem);
-}
-
-static void _php_mb_allocators_free(void *ptr)
-{
- efree(ptr);
-}
-
-static const mbfl_allocators _php_mb_allocators = {
- _php_mb_allocators_malloc,
- _php_mb_allocators_realloc,
- _php_mb_allocators_calloc,
- _php_mb_allocators_free,
-};
-/* }}} */
-
/* {{{ static sapi_post_entry mbstr_post_entries[] */
static const sapi_post_entry mbstr_post_entries[] = {
{ DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data, php_mb_post_handler },
#if defined(COMPILE_DL_MBSTRING) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
- __mbfl_allocators = (mbfl_allocators*)&_php_mb_allocators;
REGISTER_INI_ENTRIES();