Commit 06d1c0e1 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Get rid of {{{TAGMALLOC}}}. Fixes #2912. close[t:2912]

git-svn-id: file:///svn/toku/tokudb@23493 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7e247e36
...@@ -85,7 +85,6 @@ struct brtnode_nonleaf_childinfo { ...@@ -85,7 +85,6 @@ struct brtnode_nonleaf_childinfo {
typedef struct brtnode *BRTNODE; typedef struct brtnode *BRTNODE;
/* Internal nodes. */ /* Internal nodes. */
struct brtnode { struct brtnode {
enum typ_tag tag;
unsigned int nodesize; unsigned int nodesize;
int ever_been_written; int ever_been_written;
unsigned int flags; unsigned int flags;
......
...@@ -809,7 +809,7 @@ deserialize_brtnode_leaf_from_rbuf (BRTNODE result, bytevec magic, struct rbuf * ...@@ -809,7 +809,7 @@ deserialize_brtnode_leaf_from_rbuf (BRTNODE result, bytevec magic, struct rbuf *
static int static int
deserialize_brtnode_from_rbuf (BLOCKNUM blocknum, u_int32_t fullhash, BRTNODE *brtnode, struct brt_header *h, struct rbuf *rb) { deserialize_brtnode_from_rbuf (BLOCKNUM blocknum, u_int32_t fullhash, BRTNODE *brtnode, struct brt_header *h, struct rbuf *rb) {
TAGMALLOC(BRTNODE, result); BRTNODE MALLOC(result);
int r; int r;
if (result==0) { if (result==0) {
r=errno; r=errno;
...@@ -1756,7 +1756,7 @@ toku_serialize_rollback_log_to (int fd, BLOCKNUM blocknum, ROLLBACK_LOG_NODE log ...@@ -1756,7 +1756,7 @@ toku_serialize_rollback_log_to (int fd, BLOCKNUM blocknum, ROLLBACK_LOG_NODE log
static int static int
deserialize_rollback_log_from_rbuf (BLOCKNUM blocknum, u_int32_t fullhash, ROLLBACK_LOG_NODE *log_p, deserialize_rollback_log_from_rbuf (BLOCKNUM blocknum, u_int32_t fullhash, ROLLBACK_LOG_NODE *log_p,
struct brt_header *h, struct rbuf *rb) { struct brt_header *h, struct rbuf *rb) {
TAGMALLOC(ROLLBACK_LOG_NODE, result); ROLLBACK_LOG_NODE MALLOC(result);
int r; int r;
if (result==NULL) { if (result==NULL) {
r=errno; r=errno;
......
...@@ -637,7 +637,6 @@ static void ...@@ -637,7 +637,6 @@ static void
initialize_empty_brtnode (BRT t, BRTNODE n, BLOCKNUM nodename, int height, size_t suggest_mpsize) initialize_empty_brtnode (BRT t, BRTNODE n, BLOCKNUM nodename, int height, size_t suggest_mpsize)
// Effect: Fill in N as an empty brtnode. // Effect: Fill in N as an empty brtnode.
{ {
n->tag = TYP_BRTNODE;
n->nodesize = t->h->nodesize; n->nodesize = t->h->nodesize;
n->flags = t->flags; n->flags = t->flags;
n->thisnodename = nodename; n->thisnodename = nodename;
...@@ -690,7 +689,7 @@ brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *r ...@@ -690,7 +689,7 @@ brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *r
// Leave the new root pinned. // Leave the new root pinned.
// Stores the sum of the fingerprints of the children into the new node. (LAZY: Later we'll only store the fingerprints when evicting.) // Stores the sum of the fingerprints of the children into the new node. (LAZY: Later we'll only store the fingerprints when evicting.)
{ {
TAGMALLOC(BRTNODE, newroot); BRTNODE MALLOC(newroot);
int r; int r;
int new_height = nodea->height+1; int new_height = nodea->height+1;
BLOCKNUM newroot_diskoff; BLOCKNUM newroot_diskoff;
...@@ -737,7 +736,7 @@ brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *r ...@@ -737,7 +736,7 @@ brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *r
// logs the memory allocation, but not the creation of the new node // logs the memory allocation, but not the creation of the new node
int toku_create_new_brtnode (BRT t, BRTNODE *result, int height, size_t mpsize) { int toku_create_new_brtnode (BRT t, BRTNODE *result, int height, size_t mpsize) {
TAGMALLOC(BRTNODE, n); BRTNODE MALLOC(n);
int r; int r;
BLOCKNUM name; BLOCKNUM name;
toku_allocate_blocknum(t->h->blocktable, &name, t->h); toku_allocate_blocknum(t->h->blocktable, &name, t->h);
...@@ -2719,7 +2718,7 @@ int toku_open_brt (const char *fname, int is_create, BRT *newbrt, int nodesize, ...@@ -2719,7 +2718,7 @@ int toku_open_brt (const char *fname, int is_create, BRT *newbrt, int nodesize,
static int setup_initial_brt_root_node (BRT t, BLOCKNUM blocknum) { static int setup_initial_brt_root_node (BRT t, BLOCKNUM blocknum) {
int r; int r;
TAGMALLOC(BRTNODE, node); BRTNODE MALLOC(node);
assert(node); assert(node);
node->ever_been_written = 0; node->ever_been_written = 0;
//printf("%s:%d\n", __FILE__, __LINE__); //printf("%s:%d\n", __FILE__, __LINE__);
......
...@@ -76,7 +76,6 @@ enum ctpair_state { ...@@ -76,7 +76,6 @@ enum ctpair_state {
*/ */
typedef struct ctpair *PAIR; typedef struct ctpair *PAIR;
struct ctpair { struct ctpair {
enum typ_tag tag;
CACHEFILE cachefile; CACHEFILE cachefile;
CACHEKEY key; CACHEKEY key;
void *value; void *value;
...@@ -135,7 +134,6 @@ static inline void ctpair_destroy(PAIR p) { ...@@ -135,7 +134,6 @@ static inline void ctpair_destroy(PAIR p) {
// cachetable_mutex // cachetable_mutex
// cachefiles_mutex // cachefiles_mutex
struct cachetable { struct cachetable {
enum typ_tag tag;
u_int32_t n_in_table; // number of pairs in the hash table u_int32_t n_in_table; // number of pairs in the hash table
u_int32_t table_size; // number of buckets in the hash table u_int32_t table_size; // number of buckets in the hash table
PAIR *table; // hash table PAIR *table; // hash table
...@@ -270,7 +268,7 @@ u_int32_t toku_get_checkpoint_period (CACHETABLE ct) { ...@@ -270,7 +268,7 @@ u_int32_t toku_get_checkpoint_period (CACHETABLE ct) {
#define unreservable_memory(size) ((size)/4) #define unreservable_memory(size) ((size)/4)
int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN UU(initial_lsn), TOKULOGGER logger) { int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN UU(initial_lsn), TOKULOGGER logger) {
TAGMALLOC(CACHETABLE, ct); CACHETABLE MALLOC(ct);
if (ct == 0) return ENOMEM; if (ct == 0) return ENOMEM;
memset(ct, 0, sizeof(*ct)); memset(ct, 0, sizeof(*ct));
ct->table_size = 4; ct->table_size = 4;
...@@ -1271,7 +1269,7 @@ static PAIR cachetable_insert_at(CACHETABLE ct, ...@@ -1271,7 +1269,7 @@ static PAIR cachetable_insert_at(CACHETABLE ct,
CACHETABLE_FETCH_CALLBACK fetch_callback, CACHETABLE_FETCH_CALLBACK fetch_callback,
void *extraargs, void *extraargs,
enum cachetable_dirty dirty) { enum cachetable_dirty dirty) {
TAGMALLOC(PAIR, p); PAIR MALLOC(p);
assert(p); assert(p);
memset(p, 0, sizeof *p); memset(p, 0, sizeof *p);
ctpair_add_ref(p); ctpair_add_ref(p);
......
...@@ -63,7 +63,6 @@ struct logbuf { ...@@ -63,7 +63,6 @@ struct logbuf {
}; };
struct tokulogger { struct tokulogger {
enum typ_tag tag; // must be first
struct mylock input_lock; struct mylock input_lock;
toku_pthread_mutex_t output_condition_lock; // if you need both this lock and input_lock, acquire the output_lock first, then input_lock. More typical is to get the output_is_available condition to be false, and then acquire the input_lock. toku_pthread_mutex_t output_condition_lock; // if you need both this lock and input_lock, acquire the output_lock first, then input_lock. More typical is to get the output_is_available condition to be false, and then acquire the input_lock.
...@@ -117,7 +116,6 @@ struct brtcachefile_pair { ...@@ -117,7 +116,6 @@ struct brtcachefile_pair {
}; };
struct tokutxn { struct tokutxn {
enum typ_tag tag;
u_int64_t txnid64; /* this happens to be the first lsn */ u_int64_t txnid64; /* this happens to be the first lsn */
TOKULOGGER logger; TOKULOGGER logger;
TOKUTXN parent; TOKUTXN parent;
......
...@@ -52,7 +52,7 @@ static BOOL is_a_logfile (const char *name, long long *number_result) { ...@@ -52,7 +52,7 @@ static BOOL is_a_logfile (const char *name, long long *number_result) {
int toku_logger_create (TOKULOGGER *resultp) { int toku_logger_create (TOKULOGGER *resultp) {
int r; int r;
TAGMALLOC(TOKULOGGER, result); TOKULOGGER MALLOC(result);
if (result==0) return errno; if (result==0) return errno;
result->is_open=FALSE; result->is_open=FALSE;
result->is_panicked=FALSE; result->is_panicked=FALSE;
...@@ -1132,7 +1132,6 @@ int toku_txnid2txn (TOKULOGGER logger, TXNID txnid, TOKUTXN *result) { ...@@ -1132,7 +1132,6 @@ int toku_txnid2txn (TOKULOGGER logger, TXNID txnid, TOKUTXN *result) {
int r = toku_omt_find_zero(logger->live_txns, find_by_xid, &txnid, &txnfound, NULL, NULL); int r = toku_omt_find_zero(logger->live_txns, find_by_xid, &txnid, &txnfound, NULL, NULL);
if (r==0) { if (r==0) {
TOKUTXN txn = txnfound; TOKUTXN txn = txnfound;
assert(txn->tag==TYP_TOKUTXN);
assert(txn->txnid64==txnid); assert(txn->txnid64==txnid);
*result = txn; *result = txn;
rval = 0; rval = 0;
......
...@@ -37,14 +37,6 @@ void* toku_malloc(size_t n) { ...@@ -37,14 +37,6 @@ void* toku_malloc(size_t n) {
if (does_malloc_fail()) return 0; if (does_malloc_fail()) return 0;
return malloc(n); return malloc(n);
} }
void *toku_tagmalloc(size_t size, enum typ_tag typtag) {
//printf("%s:%d tagmalloc\n", __FILE__, __LINE__);
void *r = toku_malloc(size);
if (!r) return 0;
assert(size>sizeof(int));
((int*)r)[0] = typtag;
return r;
}
void *toku_memdup (const void *v, size_t len) { void *toku_memdup (const void *v, size_t len) {
void *r=toku_malloc(len); void *r=toku_malloc(len);
......
...@@ -375,7 +375,7 @@ static int toku_rollback_fetch_callback (CACHEFILE cachefile, int fd, BLOCKNUM l ...@@ -375,7 +375,7 @@ static int toku_rollback_fetch_callback (CACHEFILE cachefile, int fd, BLOCKNUM l
} }
static int toku_create_new_rollback_log (TOKUTXN txn, BLOCKNUM older, uint32_t older_hash, ROLLBACK_LOG_NODE *result) { static int toku_create_new_rollback_log (TOKUTXN txn, BLOCKNUM older, uint32_t older_hash, ROLLBACK_LOG_NODE *result) {
TAGMALLOC(ROLLBACK_LOG_NODE, log); ROLLBACK_LOG_NODE MALLOC(log);
assert(log); assert(log);
int r; int r;
......
...@@ -47,7 +47,6 @@ int toku_commit_fileentries (int fd, TOKUTXN txn, YIELDF yield,void *yieldv, LSN ...@@ -47,7 +47,6 @@ int toku_commit_fileentries (int fd, TOKUTXN txn, YIELDF yield,void *yieldv, LSN
int find_xid (OMTVALUE v, void *txnv); int find_xid (OMTVALUE v, void *txnv);
struct rollback_log_node { struct rollback_log_node {
enum typ_tag tag;
int layout_version; int layout_version;
int layout_version_original; int layout_version_original;
int layout_version_read_from_disk; int layout_version_read_from_disk;
......
...@@ -28,7 +28,7 @@ int toku_txn_begin_txn (TOKUTXN parent_tokutxn, TOKUTXN *tokutxn, TOKULOGGER log ...@@ -28,7 +28,7 @@ int toku_txn_begin_txn (TOKUTXN parent_tokutxn, TOKUTXN *tokutxn, TOKULOGGER log
int toku_txn_begin_with_xid (TOKUTXN parent_tokutxn, TOKUTXN *tokutxn, TOKULOGGER logger, TXNID xid) { int toku_txn_begin_with_xid (TOKUTXN parent_tokutxn, TOKUTXN *tokutxn, TOKULOGGER logger, TXNID xid) {
if (logger->is_panicked) return EINVAL; if (logger->is_panicked) return EINVAL;
assert(logger->rollback_cachefile); assert(logger->rollback_cachefile);
TAGMALLOC(TOKUTXN, result); TOKUTXN MALLOC(result);
if (result==0) if (result==0)
return errno; return errno;
int r; int r;
......
...@@ -16,16 +16,6 @@ extern "C" { ...@@ -16,16 +16,6 @@ extern "C" {
/* Generally: errno is set to 0 or a value to indicate problems. */ /* Generally: errno is set to 0 or a value to indicate problems. */
enum typ_tag { TYP_BRTNODE = 0xdead0001,
TYP_CACHETABLE, TYP_PAIR, /* for cachetables */
TYP_PMA,
TYP_GPMA,
TYP_TOKULOGGER,
TYP_TOKUTXN,
TYP_LEAFENTRY,
TYP_ROLLBACK_LOG_NODE
};
/* Everything should call toku_malloc() instead of malloc(), and toku_calloc() instead of calloc() */ /* Everything should call toku_malloc() instead of malloc(), and toku_calloc() instead of calloc() */
void *toku_calloc(size_t nmemb, size_t size) __attribute__((__visibility__("default"))); void *toku_calloc(size_t nmemb, size_t size) __attribute__((__visibility__("default")));
void *toku_xcalloc(size_t nmemb, size_t size) __attribute__((__visibility__("default"))); void *toku_xcalloc(size_t nmemb, size_t size) __attribute__((__visibility__("default")));
...@@ -35,11 +25,6 @@ void *toku_malloc(size_t size) __attribute__((__visibility__("default"))); ...@@ -35,11 +25,6 @@ void *toku_malloc(size_t size) __attribute__((__visibility__("default")));
void *toku_xmalloc(size_t size); void *toku_xmalloc(size_t size);
void *toku_xrealloc(void*, size_t size) __attribute__((__visibility__("default"))); void *toku_xrealloc(void*, size_t size) __attribute__((__visibility__("default")));
/* toku_tagmalloc() performs a malloc(size), but fills in the first 4 bytes with typ.
* This "tag" is useful if you are debugging and run across a void* that is
* really a (struct foo *), and you want to figure out what it is.
*/
void *toku_tagmalloc(size_t size, enum typ_tag typ);
void toku_free(void*) __attribute__((__visibility__("default"))); void toku_free(void*) __attribute__((__visibility__("default")));
/* toku_free_n() should be used if the caller knows the size of the malloc'd object. */ /* toku_free_n() should be used if the caller knows the size of the malloc'd object. */
void toku_free_n(void*, size_t size); void toku_free_n(void*, size_t size);
...@@ -79,17 +64,6 @@ void *toku_realloc(void *, size_t size) __attribute__((__visibility__("default" ...@@ -79,17 +64,6 @@ void *toku_realloc(void *, size_t size) __attribute__((__visibility__("default"
#define XCALLOC(v) XCALLOC_N(1,(v)) #define XCALLOC(v) XCALLOC_N(1,(v))
#define XREALLOC_N(n,v) v = cast_to_typeof(v) toku_xrealloc(v, (n)*sizeof(*v)) #define XREALLOC_N(n,v) v = cast_to_typeof(v) toku_xrealloc(v, (n)*sizeof(*v))
/* If you have a type such as
* struct pma *PMA;
* and you define a corresponding int constant, such as
* enum typ_tag { TYP_PMA };
* then if you do
* TAGMALLOC(PMA,v);
* you declare a variable v of type PMA and malloc a struct pma, and fill
* in that "tag" with toku_tagmalloc().
*/
#define TAGMALLOC(t,v) t v = toku_tagmalloc(sizeof(*v), TYP_ ## t);
/* Copy memory. Analogous to strdup() */ /* Copy memory. Analogous to strdup() */
void *toku_memdup (const void *v, size_t len); void *toku_memdup (const void *v, size_t len);
/* Toku-version of strdup. Use this so that it calls toku_malloc() */ /* Toku-version of strdup. Use this so that it calls toku_malloc() */
......
...@@ -35,16 +35,6 @@ toku_calloc(size_t nmemb, size_t size) ...@@ -35,16 +35,6 @@ toku_calloc(size_t nmemb, size_t size)
return vp; return vp;
} }
void *
toku_tagmalloc(size_t size, enum typ_tag typtag)
{
void *r = toku_malloc(size);
if (!r) return 0;
assert(size>sizeof(int));
((int*)r)[0] = typtag;
return r;
}
void * void *
toku_realloc(void *p, size_t size) toku_realloc(void *p, size_t size)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment