void http_header::clear() { if (url_) { acl_myfree(url_); url_ = NULL; } std::list<HttpCookie*>::iterator cookies_it = cookies_.begin(); for (; cookies_it != cookies_.end(); ++cookies_it) (*cookies_it)->destroy(); cookies_.clear(); std::list<HTTP_HDR_ENTRY*>::iterator entries_it = entries_.begin(); for (; entries_it != entries_.end(); ++entries_it) { acl_myfree((*entries_it)->name); acl_myfree((*entries_it)->value); acl_myfree(*entries_it); } entries_.clear(); std::list<HTTP_PARAM*>::iterator params_it = params_.begin(); for (; params_it != params_.end(); ++params_it) { acl_myfree((*params_it)->name); // 在调用 add_param 时允许 value 为空指针 if ((*params_it)->value) acl_myfree((*params_it)->value); acl_myfree(*params_it); } params_.clear(); }
static void io_blk_free(ZDB_IO_BLK *blk) { const char *myname = "io_blk_free"; int ret; if ((blk->flag & BLK_F_DIRTY)) { ZDB_IO *io = blk->io; avl_remove(&io->blk_tree, blk); #ifdef PWRITE ret = PWRITE(IO_HANDLE(io), blk->dat, blk->dlen, blk->off); if (ret != (int) blk->dlen) { acl_msg_error("%s(%d): pwrite to %s error(%s)," " ret(%d) != len(%d), off: " ACL_FMT_I64D, myname, __LINE__, PATH(IO_STREAM(io)), acl_last_serror(), ret, (int) blk->dlen, blk->off); } #else if (acl_vstream_fseek(IO_STREAM(io), blk->off, SEEK_SET) < 0) { acl_msg_error("%s(%d): fseek %s error(%s), off: " ACL_FMT_I64D, myname, __LINE__, IO_PATH(io), acl_last_serror(), blk->off); } else if ((ret = acl_vstream_writen(IO_STREAM(io), blk->dat, blk->dlen)) == ACL_VSTREAM_EOF) { acl_msg_error("%s(%d): readn from %s, ret(%d) != size(%d)," " off(" ACL_FMT_I64D "), error(%s)", myname, __LINE__, IO_PATH(io), ret, (int) blk->dlen, blk->off, acl_last_serror()); } #endif } if (blk->io->dat_slice) acl_slice_free2(blk->io->dat_slice, blk->dat); else acl_myfree(blk->dat); if (blk->io->blk_slice) acl_slice_free2(blk->io->blk_slice, blk); else acl_myfree(blk); __n--; }
void redis_client::set_password(const char* pass) { if (pass_) acl_myfree(pass_); if (pass && *pass) pass_ = acl_mystrdup(pass); else pass_ = NULL; }
json_node::~json_node(void) { delete parent_saved_; delete child_; if (iter_) acl_myfree(iter_); delete buf_; delete obj_; }
/** * 从一个表索引中删除该索引 * @param idx {ACL_MDT_IDX*} 表索引 * @param rec {ACL_MDT_REC*} 索引表中对应某个键的结果集对象 * @param key_value {const char*} 数据结点的引用结点的引用键值 */ static void mdt_idx_del(ACL_MDT_IDX *idx, const char *key) { const char *myname = "mdt_idx_del"; ACL_MDT_IDX_AVL *idx_avl = (ACL_MDT_IDX_AVL*) idx; TREE_NODE node, *pnode; node.key.c_key = key; pnode = (TREE_NODE*) avl_find(&idx_avl->avl, &node, NULL); if (pnode == NULL) acl_msg_fatal("%s: key(%s) not exist", myname, key); avl_remove(&idx_avl->avl, pnode); if (!(idx->flag & ACL_MDT_FLAG_KMR)) acl_myfree(pnode->key.key); if (idx_avl->slice) acl_slice_free2(idx_avl->slice, pnode); else acl_myfree(pnode); }
void query::del_param(const string& key) { std::map<string, query_param*>::iterator it = params_.find(key); if (it != params_.end()) { acl_myfree(it->second); params_.erase(it); } }
static void run_thread(void *arg) { RUN_CTX *ctx = (RUN_CTX*) arg; acl_pthread_mutex_lock(&__mutex); acl_vstream_fprintf(ctx->fp, "hello world, hello world, hello world, hello world, i: %d\n", ctx->i); acl_pthread_mutex_unlock(&__mutex); acl_myfree(ctx); }
void acl_xml_attr_free(ACL_XML_ATTR *attr) { acl_vstring_free(attr->name); acl_vstring_free(attr->value); if (attr->node->xml->slice) acl_slice_pool_free(__FILE__, __LINE__, attr); else acl_myfree(attr); }
void acl_free_ifaddrs(ACL_IFCONF *ifconf) { int i; if (ifconf == NULL) return; for (i = 0; i < ifconf->length; i++) { #ifdef WIN32 if (ifconf->addrs[i].desc != NULL) acl_myfree(ifconf->addrs[i].desc); #endif if (ifconf->addrs[i].name != NULL) acl_myfree(ifconf->addrs[i].name); } acl_myfree(ifconf->addrs); acl_myfree(ifconf); }
db_handle& db_handle::set_id(const char* id) { if (id == NULL || *id == 0) return *this; if (id_) acl_myfree(id_); id_ = acl_mystrdup(id); return *this; }
static void thread_free_dummy(void* ctx) { if ((unsigned long) acl_pthread_self() != acl_main_thread_self()) acl_myfree(ctx); #ifdef HAS_MYSQL_DLL if (__mysql_thread_end) __mysql_thread_end(); #endif }
static void run_client(const char *addr, const char *filename) { char *request = acl_vstream_loadfile(filename); ACL_VSTREAM *client; int ret; char buf[1024]; if (request == NULL) { printf("load file(%s) error(%s)\n", filename, acl_last_serror()); return; } client = acl_vstream_connect(addr, ACL_BLOCKING, 0, 0, 4096); if (client == NULL) { printf("connect addr(%s) error(%s)\n", addr, acl_last_serror()); acl_myfree(request); return; } acl_tcp_set_sndbuf(ACL_VSTREAM_SOCK(client), 10); if (acl_vstream_writen(client, request, strlen(request)) == ACL_VSTREAM_EOF) { printf("write to addr(%s) error(%s)\n", addr, acl_last_serror()); acl_vstream_close(client); acl_myfree(request); return; } memset(buf, 0, sizeof(buf)); while (1) { ret = acl_vstream_read(client, buf, sizeof(buf) - 1); if (ret == ACL_VSTREAM_EOF) break; buf[ret] = 0; usleep(100000); printf(">>>%s\n", buf); } printf(">>>last data(%s)\n", buf); acl_vstream_close(client); acl_myfree(request); }
json::~json(void) { clear(); if (json_) acl_json_free(json_); delete root_; delete buf_; if (iter_) acl_myfree(iter_); }
/* Free the semaphore */ void acl_sem_destroy(ACL_SEM *sem) { if (sem) { if (sem->id) { CloseHandle(sem->id); sem->id = 0; } acl_myfree(sem); } }
ipc_client::~ipc_client() { messages_.clear(); if (addr_) acl_myfree(addr_); if (async_stream_ && !closing_) async_stream_->close(); delete sync_stream_inner_; }
void polarssl_conf::free_ca() { #ifdef HAS_POLARSSL if (cacert_) { _X509_FREE_FN((_X509_CERT*) cacert_); acl_myfree(cacert_); cacert_ = NULL; } #endif }
static void mail_from(MIME_NODE *node, const HEADER_OPTS *header_info) { //MIME_STATE *state = node->state; TOK822 *tree; TOK822 **addr_list; TOK822 **tpp; ACL_VSTRING *temp; const char *cp; temp = acl_vstring_alloc(10); cp = STR(node->buffer) + strlen(header_info->name) + 1; tree = tok822_parse(cp); addr_list = tok822_grep(tree, TOK822_ADDR); for (tpp = addr_list; *tpp; tpp++) { tok822_internalize(temp, tpp[0]->head, TOK822_STR_DEFL); if (header_info->type == HDR_SENDER) { if (node->header_sender) acl_myfree(node->header_sender); node->header_sender = acl_mystrdup(STR(temp)); break; } else if (header_info->type == HDR_FROM) { if (node->header_from) acl_myfree(node->header_from); node->header_from = acl_mystrdup(STR(temp)); break; } else if (header_info->type == HDR_REPLY_TO) { if (node->header_replyto) acl_myfree(node->header_replyto); node->header_replyto = acl_mystrdup(STR(temp)); break; } else if (header_info->type == HDR_RETURN_PATH) { if (node->header_returnpath) acl_myfree(node->header_returnpath); node->header_returnpath = acl_mystrdup(STR(temp)); } } acl_myfree(addr_list); tok822_free_tree(tree); acl_vstring_free(temp); }
void acl_yqueue_free(ACL_YQUEUE *self, void(*free_fn)(void*)) { chunk_t *cs; if (free_fn) { if (self->begin_chunk == self->back_chunk) chunk_data_free(self->begin_chunk, self->begin_pos, self->back_pos, free_fn); else { chunk_t *begin = self->begin_chunk; chunk_t *end = self->back_chunk; int begin_pos = self->begin_pos; for (; begin != end; begin = begin->next) { chunk_data_free(begin, begin_pos, CHUNK_SIZE - 1, free_fn); begin_pos = 0; } chunk_data_free(end, 0, self->back_pos, free_fn); begin_pos = 0; } } do { chunk_t *o; if (self->begin_chunk == self->end_chunk) { acl_myfree(self->begin_chunk); break; } o = self->begin_chunk; self->begin_chunk = self->begin_chunk->next; acl_myfree(o); } while (1); cs = (chunk_t *) acl_atomic_xchg(self->spare_chunk, NULL); if (cs) acl_myfree(cs); acl_myfree(self); }
static void echo_client(ACL_FIBER *fiber, void *ctx) { ACL_VSTREAM *cstream = (ACL_VSTREAM *) ctx; char buf[8192]; int ret, count = 0; int ntimeout = 0; FIBER_TIMER *ft = (FIBER_TIMER *) acl_mymalloc(sizeof(FIBER_TIMER)); ft->fiber = fiber; ft->timer = acl_fiber_create_timer(__rw_timeout * 1000, 320000, io_timer, ft); ft->conn = cstream; #define SOCK ACL_VSTREAM_SOCK while (1) { printf("begin read\n"); ret = acl_vstream_gets(cstream, buf, sizeof(buf) - 1); if (ret == ACL_VSTREAM_EOF) { printf("fiber-%d, gets error: %s, %d, %d, fd: %d, " "count: %d\r\n", acl_fiber_id(fiber), acl_last_serror(), errno, acl_fiber_errno(fiber), SOCK(cstream), count); if (errno != ETIMEDOUT) break; if (++ntimeout > 2) { printf("too many timeout: %d\r\n", ntimeout); break; } printf("ntimeout: %d\r\n", ntimeout); ft->timer = acl_fiber_create_timer(__rw_timeout * 1000, 320000, io_timer, ft); } acl_fiber_reset_timer(ft->timer, __rw_timeout * 1000); buf[ret] = 0; //printf("gets line: %s", buf); if (acl_vstream_writen(cstream, buf, ret) == ACL_VSTREAM_EOF) { printf("write error, fd: %d\r\n", SOCK(cstream)); break; } count++; } acl_myfree(ft); acl_vstream_close(cstream); }
aio_stream::~aio_stream() { if (hook_) hook_->destroy(); if (stream_) { handle_->decrease(); acl_aio_iocp_close(stream_); } std::list<AIO_CALLBACK*>::iterator it = close_callbacks_.begin(); for (; it != close_callbacks_.end(); ++it) acl_myfree((*it)); close_callbacks_.clear(); it = timeout_callbacks_.begin(); for (; it != timeout_callbacks_.end(); ++it) acl_myfree((*it)); timeout_callbacks_.clear(); }
void tls_scache_close(TLS_SCACHE *cp) { const char *myname = "tls_scache_close"; /* * Logging. */ if (cp->verbose) acl_msg_info("%s: close %s TLS cache %s", myname, cp->cache_label, cp->db->name); /* * Destroy the TLS_SCACHE object. */ DICT_CLOSE(cp->db); acl_myfree(cp->cache_label); if (cp->saved_cursor) acl_myfree(cp->saved_cursor); acl_myfree(cp); }
xml::~xml(void) { clear(); delete root_; if (xml_) acl_xml_free(xml_); delete buf_; if (m_pTokenTree) acl_token_tree_destroy(m_pTokenTree); if (iter_) acl_myfree(iter_); }
static int _cfg_line_dump(ACL_FILE_HANDLE filefd, const ACL_CFG_LINE *cfg_line, const char *delimiter) { char myname[] = "_cfg_line_dump"; char *pbuf, *ptr; int dlen = 0, i, j, n; char tbuf[256]; n = cfg_line->ncount; if (delimiter != NULL) j = (int) strlen(delimiter); else j = 0; if (cfg_line->value != NULL) { for (i = 0; i < n; i++) { if (cfg_line->value[i] == NULL) break; dlen += (int) strlen(cfg_line->value[i]) + j; } dlen += 2; /* for '\n' and '\0' */ pbuf = (char *) acl_mycalloc(1, dlen); ptr = pbuf; for (i = 0; i < n; i++) { if (cfg_line->value[i] == NULL) break; if (i < n -1) sprintf(ptr, "%s%s", cfg_line->value[i], delimiter); else sprintf(ptr, "%s", cfg_line->value[i]); ptr = ptr + strlen(ptr); } ptr = ptr + strlen(ptr); strcat(ptr, "\n\0"); i = acl_file_write(filefd, pbuf, strlen(pbuf), 0, NULL, NULL); if (i <= 0) { printf("%s: can't write pbuf, error=%s\n", myname, acl_last_strerror(tbuf, sizeof(tbuf))); acl_myfree(pbuf); return (-1); } } else if (cfg_line->pdata != NULL) { dlen = (int) strlen(cfg_line->pdata) + 2; pbuf = (char *) acl_mycalloc(1, dlen); if (pbuf == NULL) return (-1); sprintf(pbuf, "%s\n", cfg_line->pdata); i = acl_file_write(filefd, pbuf, strlen(pbuf), 0, NULL, NULL); if (i <= 0) return (-1); } return (0); }
void acl_app_conf_unload(void) { if (__app_cfg) { acl_xinetd_cfg_free(__app_cfg); __app_cfg = NULL; } if (__app_conf_file) { acl_myfree(__app_conf_file); __app_conf_file = NULL; } }
void acl_free_app_conf_str_table(ACL_CONFIG_STR_TABLE *table) { int i; if (table == NULL) return; for (i = 0; table[i].name != 0; i++) { if (*(table[i].target) != 0) acl_myfree(*(table[i].target)); } }
void socket_stream::close_ssl() { #ifdef HAS_POLARSSL if (ssl_) { ssl_free((ssl_context*) ssl_); acl_myfree(ssl_); ssl_ = NULL; } if (ssn_) { acl_myfree(ssn_); ssn_ = NULL; } if (hs_) { acl_myfree(hs_); hs_ = NULL; } #endif }
void ssl_aio_stream::clear() { #ifdef HAS_POLARSSL if (ssl_) { ssl_free((ssl_context*) ssl_); acl_myfree(ssl_); ssl_ = NULL; } if (ssn_) { acl_myfree(ssn_); ssn_ = NULL; } if (hs_) { acl_myfree(hs_); hs_ = NULL; } #endif }
static void acl_xml_node_free(ACL_XML_NODE *node) { acl_vstring_free(node->ltag); acl_vstring_free(node->rtag); acl_vstring_free(node->text); acl_ring_detach(&node->node); acl_array_free(node->attr_list, (void (*)(void*)) acl_xml_attr_free); if (node->xml->slice) acl_slice_pool_free(__FILE__, __LINE__, node); else acl_myfree(node); }
static void __update_conf_str_vars(ACL_CONFIG_STR_TABLE cst[], const char *name, const char *value) { int i; for (i = 0; cst[i].name != 0; i++) { if (strcasecmp(cst[i].name, name) == 0) { acl_myfree(*(cst[i].target)); *(cst[i].target) = acl_mystrdup(value); } } }
static void thread_epoll_end(void *ctx) { const char *myname = "thread_epoll_end"; EPOLL_CTX *epoll_ctx = (EPOLL_CTX*) ctx; acl_msg_info("%s(%d), %s: close epoll_fd: %d, tid: %lu, %lu", __FILE__, __LINE__, myname, epoll_ctx->epfd, epoll_ctx->tid, acl_pthread_self()); close(epoll_ctx->epfd); acl_myfree(epoll_ctx); }