Commit 7b64569f 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 a346f6c7
......@@ -85,7 +85,6 @@ struct brtnode_nonleaf_childinfo {
typedef struct brtnode *BRTNODE;
/* Internal nodes. */
struct brtnode {
enum typ_tag tag;
unsigned int nodesize;
int ever_been_written;
unsigned int flags;
......
......@@ -809,7 +809,7 @@ deserialize_brtnode_leaf_from_rbuf (BRTNODE result, bytevec magic, struct rbuf *
static int
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;
if (result==0) {
r=errno;
......@@ -1756,7 +1756,7 @@ toku_serialize_rollback_log_to (int fd, BLOCKNUM blocknum, ROLLBACK_LOG_NODE log
static int
deserialize_rollback_log_from_rbuf (BLOCKNUM blocknum, u_int32_t fullhash, ROLLBACK_LOG_NODE *log_p,
struct brt_header *h, struct rbuf *rb) {
TAGMALLOC(ROLLBACK_LOG_NODE, result);
ROLLBACK_LOG_NODE MALLOC(result);
int r;
if (result==NULL) {
r=errno;
......
......@@ -637,7 +637,6 @@ static void
initialize_empty_brtnode (BRT t, BRTNODE n, BLOCKNUM nodename, int height, size_t suggest_mpsize)
// Effect: Fill in N as an empty brtnode.
{
n->tag = TYP_BRTNODE;
n->nodesize = t->h->nodesize;
n->flags = t->flags;
n->thisnodename = nodename;
......@@ -690,7 +689,7 @@ brt_init_new_root(BRT brt, BRTNODE nodea, BRTNODE nodeb, DBT splitk, CACHEKEY *r
// 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.)
{
TAGMALLOC(BRTNODE, newroot);
BRTNODE MALLOC(newroot);
int r;
int new_height = nodea->height+1;
BLOCKNUM newroot_diskoff;
......@@ -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
int toku_create_new_brtnode (BRT t, BRTNODE *result, int height, size_t mpsize) {
TAGMALLOC(BRTNODE, n);
BRTNODE MALLOC(n);
int r;
BLOCKNUM name;
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,
static int setup_initial_brt_root_node (BRT t, BLOCKNUM blocknum) {
int r;
TAGMALLOC(BRTNODE, node);
BRTNODE MALLOC(node);
assert(node);
node->ever_been_written = 0;
//printf("%s:%d\n", __FILE__, __LINE__);
......
......@@ -76,7 +76,6 @@ enum ctpair_state {
*/
typedef struct ctpair *PAIR;
struct ctpair {
enum typ_tag tag;
CACHEFILE cachefile;
CACHEKEY key;
void *value;
......@@ -135,7 +134,6 @@ static inline void ctpair_destroy(PAIR p) {
// cachetable_mutex
// cachefiles_mutex
struct cachetable {
enum typ_tag tag;
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
PAIR *table; // hash table
......@@ -270,7 +268,7 @@ u_int32_t toku_get_checkpoint_period (CACHETABLE ct) {
#define unreservable_memory(size) ((size)/4)
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;
memset(ct, 0, sizeof(*ct));
ct->table_size = 4;
......@@ -1271,7 +1269,7 @@ static PAIR cachetable_insert_at(CACHETABLE ct,
CACHETABLE_FETCH_CALLBACK fetch_callback,
void *extraargs,
enum cachetable_dirty dirty) {
TAGMALLOC(PAIR, p);
PAIR MALLOC(p);
assert(p);
memset(p, 0, sizeof *p);
ctpair_add_ref(p);
......
......@@ -63,7 +63,6 @@ struct logbuf {
};
struct tokulogger {
enum typ_tag tag; // must be first
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.
......@@ -117,7 +116,6 @@ struct brtcachefile_pair {
};
struct tokutxn {
enum typ_tag tag;
u_int64_t txnid64; /* this happens to be the first lsn */
TOKULOGGER logger;
TOKUTXN parent;
......
......@@ -52,7 +52,7 @@ static BOOL is_a_logfile (const char *name, long long *number_result) {
int toku_logger_create (TOKULOGGER *resultp) {
int r;
TAGMALLOC(TOKULOGGER, result);
TOKULOGGER MALLOC(result);
if (result==0) return errno;
result->is_open=FALSE;
result->is_panicked=FALSE;
......@@ -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);
if (r==0) {
TOKUTXN txn = txnfound;
assert(txn->tag==TYP_TOKUTXN);
assert(txn->txnid64==txnid);
*result = txn;
rval = 0;
......
......@@ -37,14 +37,6 @@ void* toku_malloc(size_t n) {
if (does_malloc_fail()) return 0;
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 *r=toku_malloc(len);
......
......@@ -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) {
TAGMALLOC(ROLLBACK_LOG_NODE, log);
ROLLBACK_LOG_NODE MALLOC(log);
assert(log);
int r;
......
......@@ -47,7 +47,6 @@ int toku_commit_fileentries (int fd, TOKUTXN txn, YIELDF yield,void *yieldv, LSN
int find_xid (OMTVALUE v, void *txnv);
struct rollback_log_node {
enum typ_tag tag;
int layout_version;
int layout_version_original;
int layout_version_read_from_disk;
......
......@@ -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) {
if (logger->is_panicked) return EINVAL;
assert(logger->rollback_cachefile);
TAGMALLOC(TOKUTXN, result);
TOKUTXN MALLOC(result);
if (result==0)
return errno;
int r;
......
......@@ -16,16 +16,6 @@ extern "C" {
/* 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() */
void *toku_calloc(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")));
void *toku_xmalloc(size_t size);
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")));
/* 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);
......@@ -79,17 +64,6 @@ void *toku_realloc(void *, size_t size) __attribute__((__visibility__("default"
#define XCALLOC(v) XCALLOC_N(1,(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() */
void *toku_memdup (const void *v, size_t len);
/* Toku-version of strdup. Use this so that it calls toku_malloc() */
......
......@@ -35,16 +35,6 @@ toku_calloc(size_t nmemb, size_t size)
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 *
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