phash_pool pcore_hash_init(const puint8 type) { plog_dbg("%s(): Инициализация пула типа %d", __PRETTY_FUNCTION__, type); phash_pool pool = pmalloc_check(__PRETTY_FUNCTION__, sizeof(struct s_phash_pool)); if (!pool) { return NULL; } pool->type = type; tommy_list *list = pmalloc_check(__PRETTY_FUNCTION__, sizeof(tommy_list)); if (!list) { free(pool); return NULL; } void *hash_struct; switch (type) { case PHASH_FAST_SEARCH: hash_struct = pmalloc_check(__PRETTY_FUNCTION__, sizeof(tommy_hashdyn)); if (!hash_struct) { free(pool); free(list); return NULL; } tommy_hashdyn_init(hash_struct); break; case PHASH_FAST_INSERT: default: hash_struct = pmalloc_check(__PRETTY_FUNCTION__, sizeof(tommy_hashtable)); if (!hash_struct) { free(pool); free(list); return NULL; } tommy_hashtable_init(hash_struct, 1024); break; } tommy_list_init(list); pool->list = list; pool->hash_struct = hash_struct; plog_dbg("%s(): Пул 0x%08X успешно создан", __PRETTY_FUNCTION__, pool); return pool; }
int main(int argc, char *argv[]) { int i; FILE *f; #ifdef PMALLOC_CHECK pmalloc_open(); #endif InitPolarization(); SetModName("spol"); if (argc == 1) { EvalFile(stdin, 1, methods); } else { for (i = 1; i < argc; i++) { f = fopen(argv[i], "r"); if (!f) { printf("Cannot open file %s, Skipping\n", argv[i]); continue; } EvalFile(f, 0, methods); } } #ifdef PMALLOC_CHECK pmalloc_check(); #endif return 0; }
static phash_object pcore_hash_newObject(const puint32 value, void* const data) { if (!data) { plog_error("%s(): Нет данных для сопоставления!", __PRETTY_FUNCTION__); return NULL; } plog_dbg("%s(): Подготовка нового объекта со значение '%d' и указателем на данные 0x%08X", __PRETTY_FUNCTION__, value, data); phash_object object = pmalloc_check(__PRETTY_FUNCTION__, sizeof(struct s_phash_object)); if (!object) { return NULL; } object->value = value; object->data = data; return object; }