这篇教程C++ zbx_malloc函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中zbx_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ zbx_malloc函数的具体用法?C++ zbx_malloc怎么用?C++ zbx_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了zbx_malloc函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: add_regexp_exvoid add_regexp_ex(zbx_vector_ptr_t *regexps, const char *name, const char *expression, int expression_type, char exp_delimiter, int case_sensitive){ zbx_expression_t *regexp; regexp = zbx_malloc(NULL, sizeof(zbx_expression_t)); regexp->name = zbx_strdup(NULL, name); regexp->expression = zbx_strdup(NULL, expression); regexp->expression_type = expression_type; regexp->exp_delimiter = exp_delimiter; regexp->case_sensitive = case_sensitive; zbx_vector_ptr_append(regexps, regexp);}
开发者ID:IsCoolEntertainment,项目名称:debpkg_zabbix,代码行数:16,
示例2: WRITEFUNCTION2static size_t WRITEFUNCTION2(void *ptr, size_t size, size_t nmemb, void *userdata){ size_t r_size = size * nmemb; /* first piece of data */ if (NULL == page.data) { page.allocated = MAX(8096, r_size); page.offset = 0; page.data = zbx_malloc(page.data, page.allocated); } zbx_strncpy_alloc(&page.data, &page.allocated, &page.offset, ptr, r_size); return r_size;}
开发者ID:nabnut,项目名称:zabbix2.0-cookies,代码行数:16,
示例3: zabbix_log/* expand the string message from a specific event handler */static char *expand_message6(const wchar_t *pname, EVT_HANDLE event){ const char *__function_name = "expand_message6"; wchar_t *pmessage = NULL; EVT_HANDLE provider = NULL; DWORD require = 0; char *out_message = NULL; char *tmp_pname = NULL; zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name); if (NULL == (provider = EvtOpenPublisherMetadata(NULL, pname, NULL, 0, 0))) { tmp_pname = zbx_unicode_to_utf8(pname); zabbix_log(LOG_LEVEL_DEBUG, "provider '%s' could not be opened: %s", strerror_from_system(GetLastError()), tmp_pname); zbx_free(tmp_pname); goto finish; } if (TRUE != EvtFormatMessage(provider, event, 0, 0, NULL, EvtFormatMessageEvent, 0, NULL, &require) ) { if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) { pmessage = zbx_malloc(pmessage, sizeof(WCHAR) * require); if (TRUE != EvtFormatMessage(provider, event, 0, 0, NULL, EvtFormatMessageEvent, require, pmessage, &require)) { zabbix_log(LOG_LEVEL_DEBUG, "formatting message failed: %s", strerror_from_system(GetLastError())); goto finish; } out_message = zbx_unicode_to_utf8(pmessage); } }finish: if (NULL != provider) EvtClose(provider); zbx_free(pmessage); zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, out_message); /* should be freed*/ return out_message;}
开发者ID:SDUATI,项目名称:Zabbix2.4.X,代码行数:48,
示例4: db_get_query_tags/****************************************************************************** * * * Function: db_get_query_tags * * * * Purpose: get event query tags from database * * * ******************************************************************************/static void db_get_query_tags(zbx_vector_ptr_t *event_queries){ DB_ROW row; DB_RESULT result; int i; char *sql = NULL; size_t sql_alloc = 0, sql_offset = 0; zbx_event_suppress_query_t *query; zbx_vector_uint64_t eventids; zbx_uint64_t eventid; zbx_tag_t *tag; zbx_vector_uint64_create(&eventids); for (i = 0; i < event_queries->values_num; i++) { query = (zbx_event_suppress_query_t *)event_queries->values[i]; zbx_vector_uint64_append(&eventids, query->eventid); } zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset, "select eventid,tag,value from problem_tag where"); DBadd_condition_alloc(&sql, &sql_alloc, &sql_offset, "eventid", eventids.values, eventids.values_num); zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset, " order by eventid"); result = DBselect("%s", sql); zbx_free(sql); i = 0; query = (zbx_event_suppress_query_t *)event_queries->values[0]; while (NULL != (row = DBfetch(result))) { ZBX_STR2UINT64(eventid, row[0]); while (query->eventid != eventid) query = (zbx_event_suppress_query_t *)event_queries->values[++i]; tag = (zbx_tag_t *)zbx_malloc(NULL, sizeof(zbx_tag_t)); tag->tag = zbx_strdup(NULL, row[1]); tag->value = zbx_strdup(NULL, row[2]); zbx_vector_ptr_append(&query->tags, tag); } DBfree_result(result); zbx_vector_uint64_destroy(&eventids);}
开发者ID:zabbix,项目名称:zabbix,代码行数:53,
示例5: zbx_get_process_username/* function 'zbx_get_process_username' require 'userName' with size 'MAX_NAME' */static int zbx_get_process_username(HANDLE hProcess, char *userName){ HANDLE tok; TOKEN_USER *ptu = NULL; DWORD sz = 0, nlen, dlen; TCHAR name[MAX_NAME], dom[MAX_NAME]; int iUse, res = FAIL; assert(userName); /* clean result; */ *userName = '/0'; /* open the processes token */ if (0 == OpenProcessToken(hProcess, TOKEN_QUERY, &tok)) return res; /* Get required buffer size and allocate the TOKEN_USER buffer */ if (0 == GetTokenInformation(tok, (TOKEN_INFORMATION_CLASS)1, (LPVOID)ptu, 0, &sz)) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto lbl_err; ptu = (PTOKEN_USER)zbx_malloc(ptu, sz); } /* Get the token user information from the access token. */ if (0 == GetTokenInformation(tok, (TOKEN_INFORMATION_CLASS)1, (LPVOID)ptu, sz, &sz)) goto lbl_err; /* get the account/domain name of the SID */ nlen = MAX_NAME; dlen = MAX_NAME; if (0 == LookupAccountSid(NULL, ptu->User.Sid, name, &nlen, dom, &dlen, (PSID_NAME_USE)&iUse)) goto lbl_err; zbx_unicode_to_utf8_static(name, userName, MAX_NAME); res = SUCCEED;lbl_err: zbx_free(ptu); CloseHandle(tok); return res;}
开发者ID:aries4,项目名称:MIRACLE-ZBX-2.0.3-NoSQL,代码行数:46,
示例6: ZBX_THREAD_ENTRY/****************************************************************************** * * * Function: main_snmptrapper_loop * * * * Purpose: SNMP trap reader's entry point * * * * Author: Rudolfs Kreicbergs * * * ******************************************************************************/ZBX_THREAD_ENTRY(snmptrapper_thread, args){ const char *__function_name = "main_snmptrapper_loop"; double sec; process_type = ((zbx_thread_args_t *)args)->process_type; server_num = ((zbx_thread_args_t *)args)->server_num; process_num = ((zbx_thread_args_t *)args)->process_num; zabbix_log(LOG_LEVEL_INFORMATION, "%s #%d started [%s #%d]", get_program_type_string(program_type), server_num, get_process_type_string(process_type), process_num); zabbix_log(LOG_LEVEL_DEBUG, "In %s() trapfile:'%s'", __function_name, CONFIG_SNMPTRAP_FILE); zbx_setproctitle("%s [connecting to the database]", get_process_type_string(process_type)); DBconnect(ZBX_DB_CONNECT_NORMAL); DBget_lastsize(); buffer = zbx_malloc(buffer, MAX_BUFFER_LEN); *buffer = '/0'; for (;;) { zbx_handle_log(); zbx_setproctitle("%s [processing data]", get_process_type_string(process_type)); sec = zbx_time(); while (SUCCEED == get_latest_data()) read_traps(); sec = zbx_time() - sec; zbx_setproctitle("%s [processed data in " ZBX_FS_DBL " sec, idle 1 sec]", get_process_type_string(process_type), sec); zbx_sleep_loop(1); } zbx_free(buffer); if (-1 != trap_fd) close(trap_fd);}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:54,
示例7: GetProcessUsername/* function 'GetProcessUsername' require 'userName' with size 'MAX_NAME' */static int GetProcessUsername(HANDLE hProcess, char *userName){ HANDLE tok; TOKEN_USER *ptu = NULL; DWORD sz = 0, nlen, dlen; char name[MAX_NAME], dom[MAX_NAME]; int iUse, res = 0; assert(userName); //clean result; *userName = '/0'; //open the processes token if (0 == OpenProcessToken(hProcess, TOKEN_QUERY, &tok)) return res; // Get required buffer size and allocate the TOKEN_USER buffer if (0 == GetTokenInformation(tok, (TOKEN_INFORMATION_CLASS)1, (LPVOID)ptu, 0, &sz)) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto lbl_err; ptu = (PTOKEN_USER)zbx_malloc(ptu, sz); } // Get the token user information from the access token. if (0 == GetTokenInformation(tok, (TOKEN_INFORMATION_CLASS)1, (LPVOID)ptu, sz, &sz)) goto lbl_err; //get the account/domain name of the SID nlen = sizeof(name); dlen = sizeof(dom); if (0 == LookupAccountSid(NULL, ptu->User.Sid, name, &nlen, dom, &dlen, (PSID_NAME_USE)&iUse)) goto lbl_err; zbx_strlcpy(userName, name, MAX_NAME); res = 1;lbl_err: zbx_free(ptu); CloseHandle(tok); return res;}
开发者ID:phedders,项目名称:zabbix,代码行数:46,
示例8: ipmi_sensor_get_id_lengthstatic zbx_ipmi_sensor_t *allocate_ipmi_sensor(zbx_ipmi_host_t *h, ipmi_sensor_t *sensor){ const char *__function_name = "allocate_ipmi_sensor"; char id_str[2 * IPMI_SENSOR_ID_SZ + 1]; zbx_ipmi_sensor_t *s; char id[IPMI_SENSOR_ID_SZ]; enum ipmi_str_type_e id_type; int id_sz, sz; char full_name[MAX_STRING_LEN]; id_sz = ipmi_sensor_get_id_length(sensor); memset(id, 0, sizeof(id)); ipmi_sensor_get_id(sensor, id, sizeof(id)); id_type = ipmi_sensor_get_id_type(sensor); zabbix_log(LOG_LEVEL_DEBUG, "In %s() sensor:'%[email C++ zbx_realloc函数代码示例 C++ zbx_json_init函数代码示例
|