当前位置: 首页>>代码示例>>C++>>正文


C++ os_calloc函数代码示例

本文整理汇总了C++中os_calloc函数的典型用法代码示例。如果您正苦于以下问题:C++ os_calloc函数的具体用法?C++ os_calloc怎么用?C++ os_calloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了os_calloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dump_registry_ignore_regex

int dump_registry_ignore_regex(syscheck_config *syscheck, char *regex, int arch) {
    OSMatch *mt_pt;
    int ign_size = 0;

    if (!syscheck->registry_ignore_regex) {
        os_calloc(2, sizeof(registry_regex),
                  syscheck->registry_ignore_regex);
        syscheck->registry_ignore_regex[0].regex = NULL;
        syscheck->registry_ignore_regex[1].regex = NULL;
    } else {
        while (syscheck->registry_ignore_regex[ign_size].regex != NULL) {
            ign_size++;
        }

        os_realloc(syscheck->registry_ignore_regex,
                   sizeof(registry_regex) * (ign_size + 2),
                   syscheck->registry_ignore_regex);
        syscheck->registry_ignore_regex[ign_size + 1].regex = NULL;
    }

    os_calloc(1, sizeof(OSMatch),
              syscheck->registry_ignore_regex[ign_size].regex);

    if (!OSMatch_Compile(regex,
                         syscheck->registry_ignore_regex[ign_size].regex, 0)) {
        mt_pt = syscheck->registry_ignore_regex[ign_size].regex;
        merror(REGEX_COMPILE, __local_name, regex, mt_pt->error);
        return (0);
    }

    syscheck->registry_ignore_regex[ign_size].arch = arch;
    return 1;
}
开发者ID:Cryptophobia,项目名称:ossec-wazuh,代码行数:33,代码来源:syscheck-config.c

示例2: SyscheckInit

/* Initialize the necessary information to process the syscheck information */
void SyscheckInit()
{
    int i = 0;

    sdb.db_err = 0;

    for (; i <= MAX_AGENTS; i++) {
        sdb.agent_ips[i] = NULL;
        sdb.agent_fps[i] = NULL;
        sdb.agent_cp[i][0] = '0';
    }

    /* Clear db memory */
    memset(sdb.buf, '\0', OS_MAXSTR + 1);
    memset(sdb.comment, '\0', OS_MAXSTR + 1);

    memset(sdb.size, '\0', OS_FLSIZE + 1);
    memset(sdb.perm, '\0', OS_FLSIZE + 1);
    memset(sdb.owner, '\0', OS_FLSIZE + 1);
    memset(sdb.gowner, '\0', OS_FLSIZE + 1);
    memset(sdb.md5, '\0', OS_FLSIZE + 1);
    memset(sdb.sha1, '\0', OS_FLSIZE + 1);
    memset(sdb.mtime, '\0', OS_FLSIZE + 1);
    memset(sdb.inode, '\0', OS_FLSIZE + 1);

    /* Create decoder */
    os_calloc(1, sizeof(OSDecoderInfo), sdb.syscheck_dec);
    sdb.syscheck_dec->id = getDecoderfromlist(SYSCHECK_MOD);
    sdb.syscheck_dec->name = SYSCHECK_MOD;
    sdb.syscheck_dec->type = OSSEC_RL;
    sdb.syscheck_dec->fts = 0;

    os_calloc(Config.decoder_order_size, sizeof(char *), sdb.syscheck_dec->fields);
    sdb.syscheck_dec->fields[SCK_FILE] = "file";
    sdb.syscheck_dec->fields[SCK_SIZE] = "size";
    sdb.syscheck_dec->fields[SCK_PERM] = "perm";
    sdb.syscheck_dec->fields[SCK_UID] = "uid";
    sdb.syscheck_dec->fields[SCK_GID] = "gid";
    sdb.syscheck_dec->fields[SCK_MD5] = "md5";
    sdb.syscheck_dec->fields[SCK_SHA1] = "sha1";
    sdb.syscheck_dec->fields[SCK_UNAME] = "uname";
    sdb.syscheck_dec->fields[SCK_GNAME] = "gname";
    sdb.syscheck_dec->fields[SCK_INODE] = "inode";

    sdb.id1 = getDecoderfromlist(SYSCHECK_MOD);
    sdb.id2 = getDecoderfromlist(SYSCHECK_MOD2);
    sdb.id3 = getDecoderfromlist(SYSCHECK_MOD3);
    sdb.idn = getDecoderfromlist(SYSCHECK_NEW);
    sdb.idd = getDecoderfromlist(SYSCHECK_DEL);

    debug1("%s: SyscheckInit completed.", ARGV0);
}
开发者ID:Cryptophobia,项目名称:ossec-wazuh,代码行数:53,代码来源:syscheck.c

示例3: dump_registry_ignore

void dump_registry_ignore(syscheck_config *syscheck, char *entry, int arch) {
    int ign_size = 0;

    if (syscheck->registry_ignore) {
        int ign_size;

        /* We do not add duplicated entries */
        for (ign_size = 0; syscheck->registry_ignore[ign_size].entry; ign_size++)
            if (syscheck->registry_ignore[ign_size].arch == arch &&
                strcmp(syscheck->registry_ignore[ign_size].entry, entry) == 0)
                return;

        os_realloc(syscheck->registry_ignore,
                   sizeof(registry) * (ign_size + 2),
                   syscheck->registry_ignore);

        syscheck->registry_ignore[ign_size + 1].entry = NULL;
    } else {
        ign_size = 0;
        os_calloc(2, sizeof(registry), syscheck->registry_ignore);
        syscheck->registry_ignore[0].entry = NULL;
        syscheck->registry_ignore[1].entry = NULL;
    }

    os_strdup(entry, syscheck->registry_ignore[ign_size].entry);
    syscheck->registry_ignore[ign_size].arch = arch;
}
开发者ID:Cryptophobia,项目名称:ossec-wazuh,代码行数:27,代码来源:syscheck-config.c

示例4: radius_copy_class

int radius_copy_class(struct radius_class_data *dst,
		      const struct radius_class_data *src)
{
	size_t i;

	if (src->attr == NULL)
		return 0;

	dst->attr = os_calloc(src->count, sizeof(struct radius_attr_data));
	if (dst->attr == NULL)
		return -1;

	dst->count = 0;

	for (i = 0; i < src->count; i++) {
		dst->attr[i].data = os_malloc(src->attr[i].len);
		if (dst->attr[i].data == NULL)
			break;
		dst->count++;
		os_memcpy(dst->attr[i].data, src->attr[i].data,
			  src->attr[i].len);
		dst->attr[i].len = src->attr[i].len;
	}

	return 0;
}
开发者ID:0x000000FF,项目名称:wpa_supplicant_for_edison,代码行数:26,代码来源:radius.c

示例5: tiz_os_calloc

void *
tiz_os_calloc (const tiz_os_t * ap_os, size_t a_size)
{
  assert (ap_os);
  assert (ap_os->p_soa);
  return os_calloc (ap_os->p_soa, a_size);
}
开发者ID:juanrubio,项目名称:tizonia-openmax-il,代码行数:7,代码来源:tizobjsys.c

示例6: tiz_os_init

OMX_ERRORTYPE
tiz_os_init (tiz_os_t ** app_os, const OMX_HANDLETYPE ap_hdl,
             tiz_soa_t * ap_soa)
{
  tiz_os_t * p_os = NULL;

  assert (app_os);
  assert (ap_hdl);

  TIZ_TRACE (ap_hdl, "Init");

  if (NULL == (p_os = (tiz_os_t *) os_calloc (ap_soa, sizeof (tiz_os_t))))
    {
      return OMX_ErrorInsufficientResources;
    }

  assert (p_os);

  if (OMX_ErrorNone != tiz_map_init (&(p_os->p_map), os_map_compare_func,
                                     os_map_free_func, NULL))
    {
      os_free (ap_soa, p_os);
      p_os = NULL;
      return OMX_ErrorInsufficientResources;
    }

  p_os->p_hdl = ap_hdl;
  p_os->p_soa = ap_soa;

  *app_os = p_os;

  return OMX_ErrorNone;
}
开发者ID:juanrubio,项目名称:tizonia-openmax-il,代码行数:33,代码来源:tizobjsys.c

示例7: os_str_stream_create

struct os_stream *
os_str_stream_create(size_t size)
{
   struct os_str_stream *stream;

   stream = (struct os_str_stream *)os_calloc(1, sizeof(*stream));
   if(!stream)
      goto no_stream;

   stream->base.close = &os_str_stream_close;
   stream->base.write = &os_str_stream_write;
   stream->base.flush = &os_str_stream_flush;
   stream->base.vprintf = &os_default_stream_vprintf;

   stream->str = os_malloc(size);
   if(!stream->str)
      goto no_str;

   stream->size = size;

   return &stream->base;

no_str:
   os_free(stream);
no_stream:
   return NULL;
}
开发者ID:1065672644894730302,项目名称:Chromium,代码行数:27,代码来源:os_stream_str.c

示例8: memset

/* os_get_unix_process_list: Get list of Unix processes */
void *os_get_process_list()
{
    int i = 1;
    pid_t max_pid = MAX_PID;
    OSList *p_list = NULL;

    char ps[OS_SIZE_1024 +1];


    /* Checking where ps is */
    memset(ps, '\0', OS_SIZE_1024 +1);
    strncpy(ps, "/bin/ps", OS_SIZE_1024);
    if(!is_file(ps))
    {
        strncpy(ps, "/usr/bin/ps", OS_SIZE_1024);
        if(!is_file(ps))
        {
            merror("%s: ERROR: 'ps' not found.", ARGV0);
            return(NULL);
        }
    }


    /* Creating process list */
    p_list = OSList_Create();
    if(!p_list)
    {
        merror(LIST_ERROR, ARGV0);
        return(NULL);
    }



    for(i = 1; i<= max_pid; i++)
    {
        /* Checking if the pid is present. */
        if((!((getsid(i) == -1)&&(errno == ESRCH))) &&
          (!((getpgid(i) == -1)&&(errno == ESRCH))))
         {
             Proc_Info *p_info;
             char *p_name;

             p_name = _os_get_runps(ps, (int)i);
             if(!p_name)
             {
                 continue;
             }

             os_calloc(1, sizeof(Proc_Info), p_info);
             p_info->p_path = p_name;
             p_info->p_name = NULL;
             OSList_AddData(p_list, p_info);
         }
    }

    return((void *)p_list);
}
开发者ID:Ar0xA,项目名称:ossec-hids,代码行数:58,代码来源:unix-process.c

示例9: gas_dialog_create

static struct gas_dialog_info *
gas_dialog_create(struct hostapd_data *hapd, const u8 *addr, u8 dialog_token)
{
	struct sta_info *sta;
	struct gas_dialog_info *dia = NULL;
	int i, j;

	sta = ap_get_sta(hapd, addr);
	if (!sta) {
		/*
		 * We need a STA entry to be able to maintain state for
		 * the GAS query.
		 */
		wpa_printf(MSG_DEBUG, "ANQP: Add a temporary STA entry for "
			   "GAS query");
		sta = ap_sta_add(hapd, addr);
		if (!sta) {
			wpa_printf(MSG_DEBUG, "Failed to add STA " MACSTR
				   " for GAS query", MAC2STR(addr));
			return NULL;
		}
		sta->flags |= WLAN_STA_GAS;
		/*
		 * The default inactivity is 300 seconds. We don't need
		 * it to be that long.
		 */
		ap_sta_session_timeout(hapd, sta, 5);
	} else {
		ap_sta_replenish_timeout(hapd, sta, 5);
	}

	if (sta->gas_dialog == NULL) {
		sta->gas_dialog = os_calloc(GAS_DIALOG_MAX,
					    sizeof(struct gas_dialog_info));
		if (sta->gas_dialog == NULL)
			return NULL;
	}

	for (i = sta->gas_dialog_next, j = 0; j < GAS_DIALOG_MAX; i++, j++) {
		if (i == GAS_DIALOG_MAX)
			i = 0;
		if (sta->gas_dialog[i].valid)
			continue;
		dia = &sta->gas_dialog[i];
		dia->valid = 1;
		dia->dialog_token = dialog_token;
		sta->gas_dialog_next = (++i == GAS_DIALOG_MAX) ? 0 : i;
		return dia;
	}

	wpa_msg(hapd->msg_ctx, MSG_ERROR, "ANQP: Could not create dialog for "
		MACSTR " dialog_token %u. Consider increasing "
		"GAS_DIALOG_MAX.", MAC2STR(addr), dialog_token);

	return NULL;
}
开发者ID:cococorp,项目名称:hostap-upstream,代码行数:56,代码来源:gas_serv.c

示例10: OS_DBD

/* OS_DBD: Monitor the alerts and insert them into the database.
 * Only return in case of error.
 */
void OS_DBD(DBConfig *db_config)
{
    time_t tm;     
    struct tm *p;       

    file_queue *fileq;
    alert_data *al_data;


    /* Getting currently time before starting */
    tm = time(NULL);
    p = localtime(&tm);	


    /* Initating file queue - to read the alerts */
    os_calloc(1, sizeof(file_queue), fileq);
    Init_FileQueue(fileq, p, 0);


    /* Creating location hash */
    db_config->location_hash = OSHash_Create();
    if(!db_config->location_hash)
    {
        ErrorExit(MEM_ERROR, ARGV0);
    }


    /* Getting maximum ID */
    db_config->alert_id = OS_SelectMaxID(db_config);
    db_config->alert_id++;


    /* Infinite loop reading the alerts and inserting them. */
    while(1)
    {
        tm = time(NULL);
        p = localtime(&tm);


        /* Get message if available (timeout of 5 seconds) */
        al_data = Read_FileMon(fileq, p, 5);
        if(!al_data)
        {
            continue;
        }


        /* Inserting into the db */
        OS_Alert_InsertDB(al_data, db_config);


        /* Clearing the memory */
        FreeAlertData(al_data);
    }
}
开发者ID:jrossi,项目名称:ossec-hids-old-unused,代码行数:58,代码来源:dbd.c

示例11: os_calloc

epbase *epoll_init(int size)
{
    epbase *base = os_calloc(sizeof(epbase));

    base->evsize = size;
    
    base->epfd = epoll_create(size);
    if (base->epfd < 0) {
        return NULL;
    }
    
    base->evlist = os_calloc(sizeof(struct epoll_event) * base->evsize);
    if (base->evlist == NULL) {
        return NULL;
    }
    
    base->eflags |= EPEDGE; // default using edge trigger.

    return base;
}
开发者ID:songshaodong,项目名称:ostrichserver,代码行数:20,代码来源:eventpoll.c

示例12: radius_msg_initialize

static int radius_msg_initialize(struct radius_msg *msg)
{
	msg->attr_pos = os_calloc(RADIUS_DEFAULT_ATTR_COUNT,
				  sizeof(*msg->attr_pos));
	if (msg->attr_pos == NULL)
		return -1;

	msg->attr_size = RADIUS_DEFAULT_ATTR_COUNT;
	msg->attr_used = 0;

	return 0;
}
开发者ID:0x000000FF,项目名称:wpa_supplicant_for_edison,代码行数:12,代码来源:radius.c

示例13: srandom_init

char *OS_AddNewAgent(const char *name, const char *ip, const char *id)
{
    FILE *fp;
    os_md5 md1;
    os_md5 md2;
    char str1[STR_SIZE + 1];
    char str2[STR_SIZE + 1];
    char *muname;
    char *finals;

    char nid[9];

    srandom_init();

    muname = getuname();

    snprintf(str1, STR_SIZE, "%d%s%d%s", (int)time(0), name, (int)random(), muname);
    snprintf(str2, STR_SIZE, "%s%s%ld", ip, id, (long int)random());
    OS_MD5_Str(str1, md1);
    OS_MD5_Str(str2, md2);

    free(muname);

    nid[8] = '\0';
    if (id == NULL) {
        int i = 1024;
        snprintf(nid, 6, "%d", i);
        while (IDExist(nid)) {
            i++;
            snprintf(nid, 6, "%d", i);
            if (i >= (MAX_AGENTS + 1024)) {
                return (NULL);
            }
        }
        id = nid;
    }

    fp = fopen(KEYSFILE_PATH, "a");
    if (!fp) {
        return (NULL);
    }

    os_calloc(2048, sizeof(char), finals);
    if (ip == NULL) {
        snprintf(finals, 2048, "%s %s any %s%s", id, name, md1, md2);
    } else {
        snprintf(finals, 2048, "%s %s %s %s%s", id, name, ip, md1, md2);
    }
    fprintf(fp, "%s\n", finals);

    fclose(fp);
    return (finals);
}
开发者ID:AiGangJingYe,项目名称:ossec-hids,代码行数:53,代码来源:validate.c

示例14: _wpa_dbus_dict_entry_get_byte_array

static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
	DBusMessageIter *iter, struct wpa_dbus_dict_entry *entry)
{
	dbus_uint32_t count = 0;
	dbus_bool_t success = FALSE;
	char *buffer, *nbuffer;

	entry->bytearray_value = NULL;
	entry->array_type = DBUS_TYPE_BYTE;

	buffer = os_calloc(BYTE_ARRAY_CHUNK_SIZE, BYTE_ARRAY_ITEM_SIZE);
	if (!buffer)
		return FALSE;

	entry->bytearray_value = buffer;
	entry->array_len = 0;
	while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_BYTE) {
		char byte;

		if ((count % BYTE_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
			nbuffer = os_realloc_array(
				buffer, count + BYTE_ARRAY_CHUNK_SIZE,
				BYTE_ARRAY_ITEM_SIZE);
			if (nbuffer == NULL) {
				os_free(buffer);
				wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_"
					   "entry_get_byte_array out of "
					   "memory trying to retrieve the "
					   "string array");
				goto done;
			}
			buffer = nbuffer;
		}
		entry->bytearray_value = buffer;

		dbus_message_iter_get_basic(iter, &byte);
		entry->bytearray_value[count] = byte;
		entry->array_len = ++count;
		dbus_message_iter_next(iter);
	}

	/* Zero-length arrays are valid. */
	if (entry->array_len == 0) {
		os_free(entry->bytearray_value);
		entry->bytearray_value = NULL;
	}

	success = TRUE;

done:
	return success;
}
开发者ID:0x000000FF,项目名称:wpa_supplicant_for_edison,代码行数:52,代码来源:dbus_dict_helpers.c

示例15: FillEvent

void FillEvent(Eventinfo *lf, const char *f_name, const SyscheckSum *sum) {
    os_strdup(f_name, lf->filename);
    os_strdup(sum->size, lf->size_after);
    lf->perm_after = sum->perm;
    os_strdup(sum->uid, lf->owner_after);
    os_strdup(sum->gid, lf->gowner_after);
    os_strdup(sum->md5, lf->md5_after);
    os_strdup(sum->sha1, lf->sha1_after);

    if (sum->uname)
        os_strdup(sum->uname, lf->uname_after);

    if (sum->gname)
        os_strdup(sum->gname, lf->gname_after);

    lf->mtime_after = sum->mtime;
    lf->inode_after = sum->inode;

    /* Fields */
    os_strdup(f_name, lf->fields[SCK_FILE]);
    os_strdup(sum->size, lf->fields[SCK_SIZE]);
    os_calloc(7, sizeof(char), lf->fields[SCK_PERM]);
    snprintf(lf->fields[SCK_PERM], 7, "%06o", sum->perm);
    os_strdup(sum->uid, lf->fields[SCK_UID]);
    os_strdup(sum->gid, lf->fields[SCK_GID]);
    os_strdup(sum->md5, lf->fields[SCK_MD5]);
    os_strdup(sum->sha1, lf->fields[SCK_SHA1]);

    if (sum->uname)
        os_strdup(sum->uname, lf->fields[SCK_UNAME]);

    if (sum->gname)
        os_strdup(sum->gname, lf->fields[SCK_GNAME]);

    if (sum->inode) {
        os_calloc(20, sizeof(char), lf->fields[SCK_INODE]);
        snprintf(lf->fields[SCK_INODE], 20, "%ld", sum->inode);
    }
}
开发者ID:Cryptophobia,项目名称:ossec-wazuh,代码行数:39,代码来源:syscheck.c


注:本文中的os_calloc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。