void* NdbMem_AllocateAlign(size_t size, size_t alignment) { /* return (void*)memalign(alignment, size); TEMP fix */ return NdbMem_Allocate(size); }
static char* NdbConfig_AllocHomePath(int _len) { int path_len; const char *path= NdbConfig_get_path(&path_len); int len= _len+path_len; char *buf= NdbMem_Allocate(len); basestring_snprintf(buf, len, "%s%s", path, DIR_SEPARATOR); return buf; }
char* NdbConfig_NdbCfgName(int with_ndb_home){ char *buf; int len= 0; if (with_ndb_home) { buf= NdbConfig_AllocHomePath(PATH_MAX); len= strlen(buf); } else buf= NdbMem_Allocate(PATH_MAX); basestring_snprintf(buf+len, PATH_MAX, "Ndb.cfg"); return buf; }
struct NdbCondition* NdbCondition_Create(void) { struct NdbCondition* tmpCond; tmpCond = (struct NdbCondition*)NdbMem_Allocate(sizeof(struct NdbCondition)); if (tmpCond == NULL) return NULL; (void)NdbCondition_Init(tmpCond); return tmpCond; }
NdbMutex* NdbMutex_Create(void) { NdbMutex* pNdbMutex; int result; pNdbMutex = (NdbMutex*)NdbMem_Allocate(sizeof(NdbMutex)); if (pNdbMutex == NULL) return NULL; result = pthread_mutex_init(pNdbMutex, NULL); assert(result == 0); return pNdbMutex; }
void *ndbd_malloc(size_t size) { void *p = NdbMem_Allocate(size); if (p) { g_allocated_memory += size; ndbd_alloc_touch_mem(p, size, 0); #ifdef TRACE_MALLOC { size_t s_m, s_k, s_b; xxx(size, &s_m, &s_k, &s_b); fprintf(stderr, "%p malloc(%um %uk %ub)", p, s_m, s_k, s_b); xxx(g_allocated_memory, &s_m, &s_k, &s_b); fprintf(stderr, "\t\ttotal(%um %uk %ub)\n", s_m, s_k, s_b); } #endif } return p; }