]> granicus.if.org Git - fribidi/commitdiff
Remove custom memory allocator
authorKhaled Hosny <khaledhosny@eglug.org>
Thu, 24 Dec 2015 07:27:47 +0000 (11:27 +0400)
committerKhaled Hosny <khaledhosny@eglug.org>
Thu, 24 Dec 2015 07:27:47 +0000 (11:27 +0400)
It have been disabled in the last release, so it just complicates the
code for no reason.

configure.ac
lib/Makefile.am
lib/fribidi-bidi.c
lib/fribidi-joining.c
lib/fribidi-mem.c [deleted file]
lib/fribidi-run.c
lib/fribidi.c
lib/mem.h [deleted file]

index 8d20a4a39ed195c6ab038efc2034327d9c1efb9f..ac80e098bb1dc812c7f829be933b3330d4e04b5e 100644 (file)
@@ -155,9 +155,6 @@ else
 fi
 AC_SUBST(FRIBIDI_NO_DEPRECATED)
 
-AC_DEFINE(USE_SIMPLE_MALLOC,1,
-         [Define to 1 if you want to use simple mallocs instead of memory chunks])
-
 # --disable-charsets
 AC_ARG_ENABLE(charsets,
               AC_HELP_STRING([--disable-charsets],
index f96bc6d084c71ee43fded7bf1d73a4ccc151888c..30496b1716464637a4258413530bc1210a7a7724 100644 (file)
@@ -43,13 +43,11 @@ libfribidi_la_SOURCES =     \
                fribidi-deprecated.c \
                fribidi-joining.c \
                fribidi-joining-types.c \
-               fribidi-mem.c \
                fribidi-mirroring.c \
                fribidi-run.c \
                fribidi-shape.c \
                joining-type.tab.i \
                joining-types.h \
-               mem.h \
                mirroring.tab.i \
                run.h
 
index 1bea6e8b4b9f8d1e0b560ac45df1a47715245e57..a48f8c97245c319d1393163dc25b2cbd3c8fcaab 100644 (file)
@@ -39,7 +39,6 @@
 #include <fribidi-mirroring.h>
 #include <fribidi-unicode.h>
 
-#include "mem.h"
 #include "bidi-types.h"
 #include "run.h"
 
index 29d0b678fcc5f7b79d08afd689c88a74a264f21c..90f0c0c6bbf06cadcf110851e61cbab7617f45af 100644 (file)
@@ -35,7 +35,6 @@
 
 #include <fribidi-joining.h>
 
-#include "mem.h"
 #include "bidi-types.h"
 #include "joining-types.h"
 
diff --git a/lib/fribidi-mem.c b/lib/fribidi-mem.c
deleted file mode 100644 (file)
index e1472cf..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/* FriBidi
- * fribidi-mem.c - memory manipulation routines
- *
- * $Id: fribidi-mem.c,v 1.8 2006-01-31 03:23:13 behdad Exp $
- * $Author: behdad $
- * $Date: 2006-01-31 03:23:13 $
- * $Revision: 1.8 $
- * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-mem.c,v $
- *
- * Authors:
- *   Behdad Esfahbod, 2001, 2002, 2004
- *
- * Copyright (C) 2004 Sharif FarsiWeb, Inc
- * Copyright (C) 2001,2002 Behdad Esfahbod
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library 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 this library, in a file named COPYING; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA
- * 
- * For licensing issues, contact <license@farsiweb.info>.
- */
-
-#include "common.h"
-
-#include "mem.h"
-
-#if FRIBIDI_USE_GLIB+0
-#else
-#if USE_SIMPLE_MALLOC+0
-#else
-
-struct _FriBidiMemChunk
-{
-  int atom_size;
-  int area_size;
-  int empty_size;
-  void *chunk;
-};
-
-FriBidiMemChunk *
-fribidi_mem_chunk_new (
-  /* input */
-  const char *name,
-  int atom_size,
-  unsigned long area_size,
-  int alloc_type
-)
-{
-  register FriBidiMemChunk *m;
-
-  fribidi_assert (area_size >= atom_size * 8);
-
-  m = (FriBidiMemChunk *) fribidi_malloc (sizeof (FriBidiMemChunk));
-  if LIKELY
-    (m)
-    {
-      m->atom_size = atom_size;
-      m->area_size = area_size;
-      m->empty_size = 0;
-      m->chunk = NULL;
-    }
-
-  return m;
-}
-
-void *
-fribidi_mem_chunk_alloc (
-  /* input */
-  FriBidiMemChunk *mem_chunk
-)
-{
-  fribidi_assert (mem_chunk);
-
-  if UNLIKELY
-    (mem_chunk->empty_size < mem_chunk->atom_size)
-    {
-      register void *chunk = fribidi_malloc (mem_chunk->area_size);
-      if LIKELY
-       (chunk)
-       {
-         if (mem_chunk->chunk)
-           *(void **) chunk =
-             (char *) mem_chunk->chunk + mem_chunk->empty_size -
-             mem_chunk->area_size;
-         chunk = (char *) chunk + mem_chunk->atom_size;
-         mem_chunk->chunk = chunk;
-         mem_chunk->empty_size = mem_chunk->area_size - mem_chunk->atom_size;
-       }
-      else
-       return NULL;
-    }
-
-  {
-    register void *m = mem_chunk->chunk;
-    mem_chunk->chunk = (char *) mem_chunk->chunk + mem_chunk->atom_size;
-    mem_chunk->empty_size -= mem_chunk->atom_size;
-
-    return m;
-  }
-}
-
-void
-fribidi_mem_chunk_destroy (
-  /* input */
-  FriBidiMemChunk *mem_chunk
-)
-{
-  register void *chunk;
-
-  fribidi_assert (mem_chunk);
-
-  chunk =
-    (char *) mem_chunk->chunk + mem_chunk->empty_size - mem_chunk->area_size;
-  while LIKELY
-    (chunk)
-    {
-      register void *tofree = chunk;
-      chunk = *(void **) chunk;
-      fribidi_free (tofree);
-    }
-  fribidi_free (mem_chunk);
-}
-
-#endif /* !USE_SIMPLE_MALLOC */
-#endif /* !FRIBIDI_USE_GLIB */
-
-/* Editor directions:
- * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
- */
index 9219ff98b88416fee0d5be0b4d68221309f279a9..3819833dd95f5063fbae5c1406a0832d2feb8740 100644 (file)
 #include <fribidi-bidi-types.h>
 
 #include "run.h"
-#include "mem.h"
 #include "bidi-types.h"
 
-#if USE_SIMPLE_MALLOC+0
-#else
-static FriBidiRun *free_runs = NULL;
-#endif
-
 FriBidiRun *
 new_run (
   void
@@ -53,29 +47,7 @@ new_run (
 {
   register FriBidiRun *run;
 
-#if USE_SIMPLE_MALLOC+0
   run = fribidi_malloc (sizeof (FriBidiRun));
-#else /* !USE_SIMPLE_MALLOC */
-  if (free_runs)
-    {
-      run = free_runs;
-      free_runs = run->next;
-    }
-  else
-    {
-      static FriBidiMemChunk *run_mem_chunk = NULL;
-
-      if UNLIKELY
-       (!run_mem_chunk)
-        run_mem_chunk = fribidi_chunk_new_for_type (FriBidiRun);
-
-      if LIKELY
-       (run_mem_chunk)
-       run = fribidi_chunk_new (FriBidiRun, run_mem_chunk);
-      else
-       run = NULL;
-    }
-#endif /* !USE_SIMPLE_MALLOC */
 
   if LIKELY
     (run)
@@ -93,12 +65,7 @@ free_run (
 )
 {
   fribidi_assert (run);
-#if USE_SIMPLE_MALLOC+0
   fribidi_free (run);
-#else /* !USE_SIMPLE_MALLOC */
-  run->next = free_runs;
-  free_runs = run;
-#endif /* !USE_SIMPLE_MALLOC */
 }
 
 FriBidiRun *
@@ -133,7 +100,6 @@ free_run_list (
 
   fribidi_validate_run_list (run_list);
 
-#if USE_SIMPLE_MALLOC+0
   {
     register FriBidiRun *pp;
 
@@ -149,10 +115,6 @@ free_run_list (
        free_run (p);
       };
   }
-#else /* !USE_SIMPLE_MALLOC */
-  run_list->prev->next = free_runs;
-  free_runs = run_list;
-#endif /* !USE_SIMPLE_MALLOC */
 }
 
 
index b09b9626946b3862ffc6b7e013e0a38e524aaca7..36b84ee20ddc49bb5eda321ffc422344808258ae 100644 (file)
@@ -78,9 +78,6 @@ const char *fribidi_version_info =
 #if DEBUG+0
   " --enable-debug"
 #endif /* DEBUG */
-#if USE_SIMPLE_MALLOC+0
-  " --enable-malloc"
-#endif /* USE_SIMPLE_MALLOC */
 #if FRIBIDI_CHARSETS+0
 #else
   " --disable-charsets"
diff --git a/lib/mem.h b/lib/mem.h
deleted file mode 100644 (file)
index ae6d3cd..0000000
--- a/lib/mem.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* FriBidi
- * mem.h - memory manipulation routines
- *
- * $Id: mem.h,v 1.7 2006-01-31 03:23:13 behdad Exp $
- * $Author: behdad $
- * $Date: 2006-01-31 03:23:13 $
- * $Revision: 1.7 $
- * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/mem.h,v $
- *
- * Author:
- *   Behdad Esfahbod, 2001, 2002, 2004
- *
- * Copyright (C) 2004 Sharif FarsiWeb, Inc
- * Copyright (C) 2001,2002 Behdad Esfahbod
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library 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 this library, in a file named COPYING; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA
- * 
- * For licensing issues, contact <license@farsiweb.info>.
- */
-#ifndef _MEM_H
-#define _MEM_H
-
-#include "common.h"
-
-#include <fribidi-types.h>
-
-#include <fribidi-begindecls.h>
-
-#if FRIBIDI_USE_GLIB+0
-
-#ifndef __FRIBIDI_DOC
-# include <glib.h>
-#endif /* !__FRIBIDI_DOC */
-
-#define FriBidiMemChunk GMemChunk
-#define FRIBIDI_ALLOC_ONLY G_ALLOC_ONLY
-#define fribidi_mem_chunk_new g_mem_chunk_new
-#define fribidi_mem_chunk_alloc g_mem_chunk_alloc
-#define fribidi_mem_chunk_destroy g_mem_chunk_destroy
-
-#else /* !FRIBIDI_USE_GLIB */
-
-typedef struct _FriBidiMemChunk FriBidiMemChunk;
-
-#define FRIBIDI_ALLOC_ONLY      1
-
-#define fribidi_mem_chunk_new FRIBIDI_PRIVATESPACE(mem_chunk_new)
-FriBidiMemChunk *
-fribidi_mem_chunk_new (
-  const char *name,
-  int atom_size,
-  unsigned long area_size,
-  int alloc_type
-)
-     FRIBIDI_GNUC_HIDDEN FRIBIDI_GNUC_MALLOC FRIBIDI_GNUC_WARN_UNUSED;
-
-#define fribidi_mem_chunk_alloc FRIBIDI_PRIVATESPACE(mem_chunk_alloc)
-     void *fribidi_mem_chunk_alloc (
-  FriBidiMemChunk *mem_chunk
-)
-     FRIBIDI_GNUC_HIDDEN FRIBIDI_GNUC_MALLOC FRIBIDI_GNUC_WARN_UNUSED;
-
-#define fribidi_mem_chunk_destroy FRIBIDI_PRIVATESPACE(mem_chunk_destroy)
-     void fribidi_mem_chunk_destroy (
-  FriBidiMemChunk *mem_chunk
-) FRIBIDI_GNUC_HIDDEN;
-
-#endif /* !FRIBIDI_USE_GLIB */
-
-#define fribidi_chunk_new(type, chunk)        ( \
-               (type *) fribidi_mem_chunk_alloc (chunk) \
-       )
-
-#define fribidi_chunk_new_for_type(type) ( \
-               fribidi_mem_chunk_new(FRIBIDI, sizeof (type), \
-                               FRIBIDI_CHUNK_SIZE, FRIBIDI_ALLOC_ONLY) \
-       )
-
-#include <fribidi-enddecls.h>
-
-#endif /* !_MEM_H */
-/* Editor directions:
- * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
- */