Skip to content

st use function instead of macro #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make st.c depended on pool_alloc.inc.h + conditional compilation
  • Loading branch information
funny-falcon committed Dec 31, 2011
commit 4fd464fed436200a005f9f42044b62cb73b2b104
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ signal.$(OBJEXT): {$(VPATH)}signal.c $(RUBY_H_INCLUDES) \
$(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h
sprintf.$(OBJEXT): {$(VPATH)}sprintf.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
{$(VPATH)}regex.h {$(VPATH)}vsnprintf.c $(ENCODING_H_INCLUDES)
st.$(OBJEXT): {$(VPATH)}st.c $(RUBY_H_INCLUDES)
st.$(OBJEXT): {$(VPATH)}st.c $(RUBY_H_INCLUDES) {$(VPATH)}pool_alloc.inc.h
strftime.$(OBJEXT): {$(VPATH)}strftime.c $(RUBY_H_INCLUDES) \
{$(VPATH)}timev.h
string.$(OBJEXT): {$(VPATH)}string.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
Expand Down
File renamed without changes.
21 changes: 17 additions & 4 deletions st.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ static void rehash(st_table *);
#define do_hash(key,table) (unsigned int)(st_index_t)(*(table)->type->hash)((key))
#define do_hash_bin(key,table) (do_hash((key), (table))%(table)->num_bins)

#define ST_USE_POOLED_ALLOCATOR
#ifdef ST_USE_POOLED_ALLOCATOR

#define ITEM_NAME entry
#define ITEM_TYPEDEF(name) st_table_entry name
#define free_entry st_free_entry
#define alloc_entry st_alloc_entry
#include "pool_alloc.inc"
#include "pool_alloc.inc.h"
#undef ITEM_NAME
#undef ITEM_TYPEDEF
#undef free_entry
Expand All @@ -91,7 +94,7 @@ typedef st_table_entry *st_table_entry_p;
#define ITEM_TYPEDEF(name) st_table_entry_p name[ST_DEFAULT_INIT_TABLE_SIZE]
#define free_entry st_free_bins11
#define alloc_entry st_alloc_bins11
#include "pool_alloc.inc"
#include "pool_alloc.inc.h"
#undef ITEM_NAME
#undef ITEM_TYPEDEF
#undef free_entry
Expand All @@ -101,13 +104,12 @@ typedef st_table_entry *st_table_entry_p;
#define ITEM_TYPEDEF(name) st_table name
#define free_entry st_dealloc_table
#define alloc_entry st_alloc_table
#include "pool_alloc.inc"
#include "pool_alloc.inc.h"
#undef ITEM_NAME
#undef ITEM_TYPEDEF
#undef free_entry
#undef alloc_entry


static st_table_entry **
st_alloc_bins(st_index_t num_bins)
{
Expand All @@ -133,6 +135,17 @@ st_free_bins(st_table_entry **bins, st_index_t num_bins)
}
}

#else

#define st_alloc_entry() alloc(st_table_entry)
#define st_free_entry(entry) free(entry)
#define st_alloc_table() alloc(st_table)
#define st_dealloc_table(table) free(table)
#define st_alloc_bins(size) (st_table_entry **)Calloc(size, sizeof(st_table_entry *))
#define st_free_bins(bins, size) free(bins)

#endif

/*
* MINSIZE is the minimum size of a dictionary.
*/
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy