本文整理汇总了C++中MEM函数的典型用法代码示例。如果您正苦于以下问题:C++ MEM函数的具体用法?C++ MEM怎么用?C++ MEM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MEM函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mod_bootstrap
static int mod_bootstrap(void *instance, CONF_SECTION *conf)
{
rlm_unbound_t *inst = instance;
inst->name = cf_section_name2(conf);
if (!inst->name) inst->name = cf_section_name1(conf);
if (inst->timeout > 10000) {
cf_log_err(conf, "timeout must be 0 to 10000");
return -1;
}
MEM(inst->xlat_a_name = talloc_typed_asprintf(inst, "%s-a", inst->name));
MEM(inst->xlat_aaaa_name = talloc_typed_asprintf(inst, "%s-aaaa", inst->name));
MEM(inst->xlat_ptr_name = talloc_typed_asprintf(inst, "%s-ptr", inst->name));
if (xlat_register(inst, inst->xlat_a_name, xlat_a, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, false) ||
xlat_register(inst, inst->xlat_aaaa_name, xlat_aaaa, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, false) ||
xlat_register(inst, inst->xlat_ptr_name, xlat_ptr, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, false)) {
cf_log_err(conf, "Failed registering xlats");
return -1;
}
return 0;
}
示例2: mod_thread_instantiate
/** Create thread-specific connections and buffers
*
* @param[in] conf section containing the configuration of this module instance.
* @param[in] instance of rlm_logtee_t.
* @param[in] el The event list serviced by this thread.
* @param[in] thread specific data.
* @return
* - 0 on success.
* - -1 on failure.
*/
static int mod_thread_instantiate(UNUSED CONF_SECTION const *conf, void *instance, fr_event_list_t *el, void *thread)
{
rlm_logtee_t *inst = talloc_get_type_abort(instance, rlm_logtee_t);
rlm_logtee_thread_t *t = talloc_get_type_abort(thread, rlm_logtee_thread_t);
MEM(t->fring = fr_fring_alloc(t, inst->buffer_depth, false));
t->inst = inst;
t->el = el;
/*
* Pre-allocate temporary attributes
*/
MEM(t->msg_pool = talloc_pool(t, 1024));
MEM(t->msg = fr_pair_afrom_da(t->msg_pool, attr_log_message));
MEM(t->type = fr_pair_afrom_da(t, attr_log_type));
MEM(t->lvl = fr_pair_afrom_da(t, attr_log_level));
/*
* This opens the outbound connection
*/
t->conn = fr_connection_alloc(t, el, &inst->connection_timeout, &inst->reconnection_delay,
_logtee_conn_init, _logtee_conn_open, _logtee_conn_close,
inst->name, t);
if (t->conn == NULL) return -1;
fr_connection_signal_init(t->conn);
return 0;
}
示例3: solve
int solve(){
//Init
MEM(lx, 0); MEM(ly, 0);
MEM(left, 0);
for (int i = 1; i <= sv; i ++)
for (int j = 1; j <= tv; j ++)
lx[i] = max(lx[i], w[i][j]);
//Main
for (int i = 1; i <= sv; i ++){
for (int j = 1; j <= tv; j ++) slack[j] = oo;
while(1){
MEM(S, false); MEM(T, false);
if (cross_path(i)){
break;
}
else{
int d = oo;
for (int j = 1; j <= tv; j ++)
if (!T[j]) d = min(d, slack[j]);
for (int j = 1; j <= sv; j ++)
if (S[j]) lx[j] -= d;
for (int j = 1; j <= tv; j ++){
if (T[j]) ly[j] += d;
else slack[j] -= d;
//匈牙利树中T集点ly不变,S集点lx减小,更新slack值
}
}
}
}
int res = 0;
for(int i = 1; i <= sv; i ++) res += lx[i];
for(int i = 1; i <= tv; i ++) res += ly[i];
return res;
}
示例4: mrc_dump_process
void mrc_dump_process()
{
/* generate instruction into uncacheable memory (else we would have to flush I and D caches) */
void *alloc_buf = malloc(32);
void *func_buf = UNCACHEABLE(alloc_buf);
unsigned int addr_func = (unsigned int)UNCACHEABLE(func_buf);
unsigned int (*func)() = (unsigned int (*)())addr_func;
/* build MRC instruction */
unsigned int instr = 0xEE100010;
instr |= (mrc_op1<<21);
instr |= (mrc_crn<<16);
instr |= (0<<12);
instr |= (mrc_cp<<8);
instr |= (mrc_op2<<5);
instr |= mrc_crm;
/* write along with RET */
MEM(addr_func) = instr;
MEM(addr_func + 4) = 0xE1A0F00E;
/* call generated code */
mrc_value = func();
free(alloc_buf);
}
示例5: MEM
void NameList::grow()
{
int newmax=max+GRANULARITY;
names=(char**)realloc(names, newmax*sizeof(char*)); MEM(names);
touched=(bool*)realloc(touched, newmax*sizeof(bool)); MEM(touched);
max=newmax;
}
示例6: ceil
void LookupGrid::doneSizing(void)
{
rvfloat size_x1, size_x2, size_z1, size_z2;
int i;
size_x1 = (xhi-xlo)/60.0; size_z1= (zhi-zlo)/60.0;
size_x2 = size_z2 = 500.0;
data.raster_size=rint((size_x1+ size_x2+ size_z1+ size_z2) / 4.0);
data.x0 = xlo;
data.z0 = zlo;
data.x_size = ceil((xhi-xlo)/data.raster_size);
data.z_size = ceil((zhi-zlo)/data.raster_size);
xsz=(int)data.x_size; zsz=(int)data.z_size;
ichains=new IndexChain*[zsz*xsz]; MEM(ichains);
for(i=0;i<zsz*xsz;i++)
{
ichains[i]=new IndexChain; MEM(ichains[i]);
};
lprintf(3,"LookupGrid: bounds are X(%g..%g), Z(%g..%g)\n",xlo,xhi,zlo,zhi);
lprintf(3,"LookupGrid: created %dx%d grid\n",xsz,zsz);
lprintf(3,"LookupGrid: origin (%g,%g), raster_size %g\n",data.x0,data.z0,data.raster_size);
}
示例7: main
int main(int argc, char **argv)
{
int i;
unsigned long t;
setvbuf(stdout, (char *) NULL, _IOLBF, 0);
if (argc != 2 && argc != 3)
{
fprintf(stderr, "syntax: %s input_file [-r]\n", argv[0]);
return 1;
}
if (*argv[1] == '-')
{
fprintf(stderr, "syntax: %s input_file [-r]\n", argv[0]);
return 1;
}
if ((FP = fopen(argv[1], "r")) == NULL)
{
fprintf(stderr, "%s: cannot open input file %s\n", argv[0], argv[1]);
return 1;
}
if (argc == 3)
{
if (strcmp(argv[2], "-r") == 0)
{
Redir = (char *) RedirPrefix;
fprintf(stdout, "%s\n", argv[0]);
}
else
{
fprintf(stderr, "syntax: %s input_file [-r]\n", argv[0]);
return 1;
}
}
memset(Mem, 0, MEMSIZE * sizeof(unsigned));
for (i = PCINIT; !feof(FP); i += 4)
{
if (fgets(Buf, BUFSIZE, FP) == NULL)
{
if (feof(FP))
break;
fprintf(stderr, "%s: file %s reading error\n", argv[0], argv[1]);
return 1;
}
if (sscanf(Buf, "%lx", &t) != 1)
{
fprintf(stderr, "%s: file %s error in line %d, continue...\n",
argv[0], argv[1], i - PCINIT + 1);
MEM(i) = 0;
}
else
{
MEM(i) = strtoul(Buf, (char **) NULL, 16);
}
}
Loop();
fclose(FP);
return 0;
}
示例8: uemd_em_init
void uemd_em_init(void)
{
MEM(0x2003c050)=0x9; //DDR PHY ODT ON
ddr_init(DMC0_APB_BASE);
MEM(0x2003c064)=0x9; //DDR PHY ODT ON
ddr_init(DMC1_APB_BASE);
}
示例9: qfio_read
void qfio_read(char* buf, int num) // read "num" bytes from QEMU FIO buffer, into "buf"
{
MEM(REG_FIO_BUFFER_SEEK) = 0;
for (int i = 0; i < num; i++)
{
buf[i] = MEM(REG_FIO_BUFFER);
}
}
示例10: MEM
/*
* Convert a buffer to a CSV entry
*/
static rlm_csv_entry_t *file2csv(CONF_SECTION *conf, rlm_csv_t *inst, int lineno, char *buffer)
{
rlm_csv_entry_t *e;
int i;
char *p, *q;
MEM(e = (rlm_csv_entry_t *)talloc_zero_array(inst->tree, uint8_t,
sizeof(*e) + inst->used_fields + sizeof(e->data[0])));
talloc_set_type(e, rlm_csv_entry_t);
for (p = buffer, i = 0; p != NULL; p = q, i++) {
if (!buf2entry(inst, p, &q)) {
cf_log_err(conf, "Malformed entry in file %s line %d", inst->filename, lineno);
return NULL;
}
if (q) *(q++) = '\0';
if (i >= inst->num_fields) {
cf_log_err(conf, "Too many fields at file %s line %d", inst->filename, lineno);
return NULL;
}
/*
* This is the key field.
*/
if (i == inst->key_field) {
e->key = talloc_typed_strdup(e, p);
continue;
}
/*
* This field is unused. Ignore it.
*/
if (inst->field_offsets[i] < 0) continue;
MEM(e->data[inst->field_offsets[i]] = talloc_typed_strdup(e, p));
}
if (i < inst->num_fields) {
cf_log_err(conf, "Too few fields at file %s line %d (%d < %d)", inst->filename, lineno, i, inst->num_fields);
return NULL;
}
/*
* FIXME: Allow duplicate keys later.
*/
if (!rbtree_insert(inst->tree, e)) {
cf_log_err(conf, "Failed inserting entry for filename %s line %d: duplicate entry",
inst->filename, lineno);
return NULL;
}
return e;
}
示例11: debug_console_getc
int debug_console_getc(void)
{
char c;
// Wait until the serial RX buffer is not empty
while (MEM(SERIAL_BASE + SERIAL_FLAG_REGISTER) & (SERIAL_RX_BUFFER_EMPTY))
;
c = 0xFF & MEM(SERIAL_BASE);
return c;
}
示例12: debug_console_getc
int debug_console_getc(void)
{
char c;
// Wait until the serial RX buffer is not empty
while(!MEM(DEBUG_CONSOLE_SERIAL_BASE + SERIAL_FLAG_REGISTER) & SERIAL_RX_READY)
;
c = 0xFF & MEM(DEBUG_CONSOLE_SERIAL_BASE);
return c;
}
示例13: compute_keys
int compute_keys(UNUSED REQUEST *request, pwd_session_t *session, uint8_t *peer_confirm, uint8_t *msk, uint8_t *emsk)
{
HMAC_CTX *hmac_ctx;
uint8_t mk[SHA256_DIGEST_LENGTH], *cruft;
uint8_t session_id[SHA256_DIGEST_LENGTH + 1];
uint8_t msk_emsk[128]; /* 64 each */
int offset;
MEM(cruft = talloc_array(session, uint8_t, BN_num_bytes(session->prime)));
MEM(hmac_ctx = HMAC_CTX_new());
/*
* first compute the session-id = TypeCode | H(ciphersuite | scal_p |
* scal_s)
*/
session_id[0] = FR_EAP_METHOD_PWD;
HMAC_Init_ex(hmac_ctx, allzero, SHA256_DIGEST_LENGTH, EVP_sha256(), NULL);
HMAC_Update(hmac_ctx, (uint8_t *)&session->ciphersuite, sizeof(session->ciphersuite));
offset = BN_num_bytes(session->order) - BN_num_bytes(session->peer_scalar);
memset(cruft, 0, BN_num_bytes(session->prime));
BN_bn2bin(session->peer_scalar, cruft + offset);
HMAC_Update(hmac_ctx, cruft, BN_num_bytes(session->order));
offset = BN_num_bytes(session->order) - BN_num_bytes(session->my_scalar);
memset(cruft, 0, BN_num_bytes(session->prime));
BN_bn2bin(session->my_scalar, cruft + offset);
HMAC_Update(hmac_ctx, cruft, BN_num_bytes(session->order));
pwd_hmac_final(hmac_ctx, (uint8_t *)&session_id[1]);
/* then compute MK = H(k | commit-peer | commit-server) */
HMAC_Init_ex(hmac_ctx, allzero, SHA256_DIGEST_LENGTH, EVP_sha256(), NULL);
memset(cruft, 0, BN_num_bytes(session->prime));
offset = BN_num_bytes(session->prime) - BN_num_bytes(session->k);
BN_bn2bin(session->k, cruft + offset);
HMAC_Update(hmac_ctx, cruft, BN_num_bytes(session->prime));
HMAC_Update(hmac_ctx, peer_confirm, SHA256_DIGEST_LENGTH);
HMAC_Update(hmac_ctx, session->my_confirm, SHA256_DIGEST_LENGTH);
pwd_hmac_final(hmac_ctx, mk);
/* stretch the mk with the session-id to get MSK | EMSK */
eap_pwd_kdf(mk, SHA256_DIGEST_LENGTH, (char const *)session_id,
SHA256_DIGEST_LENGTH + 1, msk_emsk, 1024); /* it's bits, ((64 + 64) * 8) */
memcpy(msk, msk_emsk, 64);
memcpy(emsk, msk_emsk + 64, 64);
HMAC_CTX_free(hmac_ctx);
talloc_free(cruft);
return 0;
}
示例14: prefix_suffix_cmp
/*
* Compare prefix/suffix.
*
* If they compare:
* - if FR_STRIP_USER_NAME is present in check_list,
* strip the username of prefix/suffix.
* - if FR_STRIP_USER_NAME is not present in check_list,
* add a FR_STRIPPED_USER_NAME to the request.
*/
static int prefix_suffix_cmp(UNUSED void *instance,
REQUEST *request,
VALUE_PAIR *req,
VALUE_PAIR *check,
VALUE_PAIR *check_list,
UNUSED VALUE_PAIR **reply_list)
{
VALUE_PAIR *vp;
char const *name;
char rest[FR_MAX_STRING_LEN];
int len, namelen;
int ret = -1;
if (!request || !request->username) return -1;
VP_VERIFY(check);
name = request->username->vp_strvalue;
RDEBUG3("Comparing name \"%s\" and check value \"%s\"", name, check->vp_strvalue);
len = strlen(check->vp_strvalue);
if (check->da == attr_prefix) {
ret = strncmp(name, check->vp_strvalue, len);
if (ret == 0)
strlcpy(rest, name + len, sizeof(rest));
} else if (check->da == attr_suffix) {
namelen = strlen(name);
if (namelen >= len) {
ret = strcmp(name + namelen - len, check->vp_strvalue);
if (ret == 0) strlcpy(rest, name, namelen - len + 1);
}
}
if (ret != 0) return ret;
/*
* If Strip-User-Name == No, then don't do any more.
*/
vp = fr_pair_find_by_da(check_list, attr_strip_user_name, TAG_ANY);
if (vp && !vp->vp_uint32) return ret;
/*
* See where to put the stripped user name.
*/
vp = fr_pair_find_by_da(check_list, attr_stripped_user_name, TAG_ANY);
if (!vp) {
/*
* If "request" is NULL, then the memory will be
* lost!
*/
MEM(vp = fr_pair_afrom_da(request->packet, attr_stripped_user_name));
fr_pair_add(&req, vp);
request->username = vp;
}
fr_pair_value_strcpy(vp, rest);
return ret;
}
示例15: main
int main(int argc, char **argv)
{
AppOptions appopt;
appopt.cmd=CmdVis;
appopt.parse(argc, argv);
msglevel=appopt.msglevel;
appopt.welcome();
if(appopt.listsyntax_only)
{
dump_visfile_syntax();
}
else if(appopt.listobj_only)
{
ASEParser p(appopt.ase_name);
p.parse(NULL, NULL, NULL);
}
else
{
ASEMeshList *meshes=new ASEMeshList(); MEM(meshes);
ASEParser p(appopt.ase_name);
p.parse(meshes, NULL, appopt.names);
BoxList *b=meshes->createBoxes(appopt.list_name, /*vis=*/true);
b->write_vis(appopt.out_name, appopt.safety_dist, 0.0);
delete b;
appopt.warn_untouched();
delete meshes;
}
return 0;
}