static void osd_setWorkingDirectory (void) { # if defined (UNIX) char *buf = dmalloc (sizeof (*buf) * MAXPATHLEN); char *cwd = getcwd (buf, MAXPATHLEN); #elif defined (OS2) char *buf = dmalloc (sizeof (*buf) * MAXPATHLEN); char *cwd = _getcwd2 (buf, MAXPATHLEN); char *slash; while ((slash = strchr (cwd, '/')) != NULL) { *slash = '\\'; } #endif # if defined (UNIX) || defined (OS2) llassert (cstring_isUndefined (osd_cwd)); if (cwd == NULL) { lldiagmsg (message ("Cannot get working directory: %s\n", lldecodeerror (errno))); osd_cwd = cstring_makeLiteral ("<missing directory>"); } else { osd_cwd = cstring_fromCharsNew (cwd); } sfree (buf); # else ; /* Don't know how to do this for non-POSIX platforms */ # endif }
uentryList uentryList_copy (uentryList s) { if (uentryList_isDefined (s)) { uentryList t = (uentryList) dmalloc (sizeof (*t)); int i; t->nelements = s->nelements; t->nspace = 0; t->current = s->current; if (s->nelements > 0) { t->elements = (uentry *) dmalloc (sizeof (*t->elements) * t->nelements); for (i = 0; i < s->nelements; i++) { t->elements[i] = uentry_copy (s->elements[i]); } } else { t->elements = NULL; } return t; } else { return uentryList_undefined; } }
struct String *string_new(char* str) { struct String* newString = (struct String*)dmalloc(sizeof(struct String)); newString->len = strlen(str); newString->cap = newString->len == 0 ? 1 : newString->len; newString->str = (char*)dmalloc(newString->cap + 1); strcpy(newString->str, str); return newString; }
struct String *string_clone(struct String* s) { struct String* newString = (struct String*)dmalloc(sizeof(struct String)); newString->len = s->len; newString->cap = s->len; newString->str = (char*)dmalloc(s->len + 1); strcpy(newString->str, s->str); return newString; }
int load_uname_pwd_from_miCASA (char **ldap_username, char **ldap_password) { int result = 0; uint32_t credentialtype = SSCS_CRED_TYPE_SERVER_F; SSCS_BASIC_CREDENTIAL credential; SSCS_SECRET_ID_T applicationSecretId; char *tempVar = NULL; const char applicationName[10] = "dhcp-ldap"; if ( load_casa() ) { memset(&credential, 0, sizeof(SSCS_BASIC_CREDENTIAL)); memset(&applicationSecretId, 0, sizeof(SSCS_SECRET_ID_T)); applicationSecretId.len = strlen(applicationName) + 1; memcpy (applicationSecretId.id, applicationName, applicationSecretId.len); credential.unFlags = USERNAME_TYPE_CN_F; result = p_miCASAGetCredential (0, &applicationSecretId,NULL,&credentialtype, &credential,NULL); if(credential.unLen) { tempVar = dmalloc (credential.unLen + 1, MDL); if (!tempVar) log_fatal ("no memory for ldap_username"); memcpy(tempVar , credential.username, credential.unLen); *ldap_username = tempVar; tempVar = dmalloc (credential.pwordLen + 1, MDL); if (!tempVar) log_fatal ("no memory for ldap_password"); memcpy(tempVar, credential.password, credential.pwordLen); *ldap_password = tempVar; #if defined (DEBUG_LDAP) log_info ("Authentication credential taken from CASA"); #endif release_casa(); return 1; } else { release_casa(); return 0; } } else return 0; //casa libraries not loaded }
static RegInfo *tf_reg_compile_fl(const char *pattern, int optimize, const char *file, int line) { RegInfo *ri; const char *emsg, *s; int eoffset, n; /* PCRE_DOTALL optimizes patterns starting with ".*" */ int options = PCRE_DOLLAR_ENDONLY | PCRE_DOTALL | PCRE_CASELESS; ri = dmalloc(NULL, sizeof(RegInfo), file, line); if (!ri) return NULL; ri->extra = NULL; ri->ovector = NULL; ri->Str = NULL; ri->links = 1; if (warn_curly_re && (s = estrchr(pattern, '{', '\\')) && (is_digit(s[1]) || s[1] == ',')) { wprintf("regexp contains '{', which has a new meaning in version 5.0. " "(This warning can be disabled with '/set warn_curly_re=off'.)"); } for (s = pattern; *s; s++) { if (*s == '\\') { if (s[1]) s++; } else if (is_upper(*s)) { options &= ~PCRE_CASELESS; break; } } ri->re = pcre_compile((char*)pattern, options, &emsg, &eoffset, re_tables); if (!ri->re) { /* don't trust emsg to be non-NULL or NUL-terminated */ eprintf("regexp error: character %d: %.128s", eoffset, emsg ? emsg : "unknown error"); goto tf_reg_compile_error; } n = pcre_info(ri->re, NULL, NULL); if (n < 0) goto tf_reg_compile_error; ri->ovecsize = 3 * (n + 1); ri->ovector = dmalloc(NULL, sizeof(int) * ri->ovecsize, file, line); if (!ri->ovector) goto tf_reg_compile_error; if (optimize) { ri->extra = pcre_study(ri->re, 0, &emsg); if (emsg) { eprintf("regexp study error: %.128s", emsg); goto tf_reg_compile_error; } } return ri; tf_reg_compile_error: tf_reg_free(ri); return NULL; }
sortSet sortSet_new () { sortSet s = (sortSet) dmalloc (sizeof (*s)); s->entries = 0; s->nspace = sortSetBASESIZE; s->elements = (sort *) dmalloc (sizeof (*s->elements) * sortSetBASESIZE); return (s); }
static /*@notnull@*/ mtMergeClauseList mtMergeClauseList_newEmpty (void) { mtMergeClauseList s = (mtMergeClauseList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = mtMergeClauseListBASESIZE; s->elements = (mtMergeClause *) dmalloc (sizeof (*s->elements) * mtMergeClauseListBASESIZE); return (s); }
static /*@notnull@*/ cstringList cstringList_newPredict (int size) { cstringList s = (cstringList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = size; s->elements = (cstring *) dmalloc (sizeof (*s->elements) * size); return (s); }
static /*@notnull@*/ cstringList cstringList_newEmpty (void) { cstringList s = (cstringList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = cstringListBASESIZE; s->elements = (cstring *) dmalloc (sizeof (*s->elements) * cstringListBASESIZE); return (s); }
static /*@only@*/ /*@notnull@*/ qualList qualList_newEmpty (void) { qualList s = (qualList) dmalloc (sizeof (*s)); s->nelements = 0; s->free = qualListBASESIZE; s->elements = (qual *) dmalloc (sizeof (*s->elements) * qualListBASESIZE); return (s); }
/*@only@*/ constraintList constraintList_makeNew () { constraintList s = (constraintList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = constraintListBASESIZE; s->elements = (constraint *) dmalloc (sizeof (*s->elements) * constraintListBASESIZE); return (s); }
static /*@only@*/ /*@notnull@*/ sRefList sRefList_newEmpty (void) { sRefList s = (sRefList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = sRefListBASESIZE; s->elements = (sRef *) dmalloc (sizeof (*s->elements) * sRefListBASESIZE); return (s); }
varDeclarationNodeList varDeclarationNodeList_new () { varDeclarationNodeList s = (varDeclarationNodeList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = varDeclarationNodeListBASESIZE; s->elements = (varDeclarationNode *) dmalloc (sizeof (*s->elements) * varDeclarationNodeListBASESIZE); return (s); }
/*@only@*/ paramNodeList paramNodeList_single (/*@keep@*/ paramNode p) { paramNodeList s = (paramNodeList) dmalloc (sizeof (*s)); s->nelements = 1; s->nspace = paramNodeListBASESIZE - 1; s->elements = (paramNode *) dmalloc (sizeof (*s->elements) * paramNodeListBASESIZE); s->elements[0] = p; return (s); }
/*@only@*/ paramNodeList paramNodeList_new () { paramNodeList s = (paramNodeList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = paramNodeListBASESIZE; s->elements = (paramNode *) dmalloc (sizeof (*s->elements) * paramNodeListBASESIZE); return (s); }
/*@only@*/ sRefSet sRefSet_single (/*@exposed@*/ sRef sr) { sRefSet s = (sRefSet) dmalloc (sizeof (*s)); s->entries = 1; s->nspace = sRefSetBASESIZE - 1; s->elements = (sRef *) dmalloc (sizeof (*s->elements) * sRefSetBASESIZE); s->elements[0] = sr; return (s); }
declaratorNodeList declaratorNodeList_new () { declaratorNodeList s = (declaratorNodeList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = declaratorNodeListBASESIZE; s->elements = (declaratorNode *) dmalloc (sizeof (*s->elements) * declaratorNodeListBASESIZE); return (s); }
/*@only@*/ traitRefNodeList traitRefNodeList_new () { traitRefNodeList s = (traitRefNodeList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = traitRefNodeListBASESIZE; s->elements = (traitRefNode *) dmalloc (sizeof (*s->elements) * traitRefNodeListBASESIZE); return (s); }
/*@only@*/ quantifierNodeList quantifierNodeList_new () { quantifierNodeList s = (quantifierNodeList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = quantifierNodeListBASESIZE; s->elements = (quantifierNode *) dmalloc (sizeof (*s->elements) * quantifierNodeListBASESIZE); return (s); }
dhcpctl_status dhcpctl_new_authenticator (dhcpctl_handle *h, const char *name, const char *algorithm, const unsigned char *secret, unsigned secret_len) { struct auth_key *key = (struct auth_key *)0; isc_result_t status; status = omapi_auth_key_new (&key, MDL); if (status != ISC_R_SUCCESS) return status; key -> name = dmalloc (strlen (name) + 1, MDL); if (!key -> name) { omapi_auth_key_dereference (&key, MDL); return ISC_R_NOMEMORY; } strcpy (key -> name, name); /* If the algorithm name isn't an FQDN, tack on the .SIG-ALG.REG.NET. domain. */ if (strchr (algorithm, '.') == 0) { static char add[] = ".SIG-ALG.REG.INT."; key -> algorithm = dmalloc (strlen (algorithm) + sizeof (add), MDL); if (!key -> algorithm) { omapi_auth_key_dereference (&key, MDL); return ISC_R_NOMEMORY; } strcpy (key -> algorithm, algorithm); strcat (key -> algorithm, add); } else { key -> algorithm = dmalloc (strlen (algorithm) + 1, MDL); if (!key -> algorithm) { omapi_auth_key_dereference (&key, MDL); return ISC_R_NOMEMORY; } strcpy (key -> algorithm, algorithm); } status = omapi_data_string_new (&key -> key, secret_len, MDL); if (status != ISC_R_SUCCESS) { omapi_auth_key_dereference (&key, MDL); return status; } memcpy (key -> key -> value, secret, secret_len); key -> key -> len = secret_len; *h = (dhcpctl_handle) key; return ISC_R_SUCCESS; }
/*@only@*/ /*@notnull@*/ uentryList uentryList_new () { uentryList s = (uentryList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspace = uentryListBASESIZE; s->elements = (uentry *) dmalloc (sizeof (*s->elements) * uentryListBASESIZE); s->current = 0; return (s); }
/*@only@*/ uentryList uentryList_single (/*@keep@*/ uentry el) { uentryList s = (uentryList) dmalloc (sizeof (*s)); s->nelements = 1; s->nspace = uentryListBASESIZE - 1; s->elements = (uentry *) dmalloc (sizeof (*s->elements) * uentryListBASESIZE); s->elements[0] = el; s->current = 0; return (s); }
/*@only@*/ interfaceNodeList interfaceNodeList_new () { interfaceNodeList s = (interfaceNodeList) dmalloc (sizeof (*s)); s->nelements = 0; s->nspacelow = interfaceNodeListGROWLOW; s->nspacehigh = interfaceNodeListGROWHI; s->elementsroot = (interfaceNode *) dmalloc (sizeof (*s->elements) * interfaceNodeListBASESIZE); s->elements = s->elementsroot + interfaceNodeListGROWLOW; return (s); }
/*@notnull@*/ metaStateInfo metaStateInfo_create (cstring name, cstringList valueNames, mtContextNode context, stateCombinationTable sctable, stateCombinationTable mergetable, fileloc loc) { metaStateInfo res = (metaStateInfo) dmalloc (sizeof (*res)); int i; res->name = name; res->valueNames = valueNames; res->context = context; res->sctable = sctable; res->mergetable = mergetable; res->loc = loc; for (i = 0; i < MTC_NUMCONTEXTS; i++) { res->defaultValue[i] = stateValue_error; } llassert (stateCombinationTable_size (res->sctable) == cstringList_size (res->valueNames)); return res; }
void val_gen_setup(WT_RAND_STATE *rnd, WT_ITEM *value) { size_t i, len; char *p; memset(value, 0, sizeof(WT_ITEM)); /* * Set initial buffer contents to recognizable text. * * Add a few extra bytes in order to guarantee we can always offset * into the buffer by a few extra bytes, used to generate different * data for column-store run-length encoded files. */ len = MAX(KILOBYTE(100), g.c_value_max) + 20; p = dmalloc(len); for (i = 0; i < len; ++i) p[i] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i % 26]; value->mem = p; value->memsize = len; value->data = value->mem; value->size = 0; val_dup_data_len = value_len(rnd, (uint64_t)mmrand(rnd, 1, 20), g.c_value_min, g.c_value_max); }
stateClause stateClause_create (lltok tok, qual q, sRefSet s) { stateClause ret = (stateClause) dmalloc (sizeof (*ret)); if (lltok_getTok (tok) == QPRECLAUSE) { ret->state = TK_BEFORE; } else if (lltok_getTok (tok) == QPOSTCLAUSE) { ret->state = TK_AFTER; } else { BADBRANCH; } ret->loc = fileloc_copy (lltok_getLoc (tok)); ret->squal = q; ret->refs = s; if (sRefSet_isDefined (s)) { ret->kind = SP_QUAL; } else { ret->kind = SP_GLOBAL; } return ret; }
isc_result_t dns_zone_lookup (struct dns_zone **zone, const char *name) { struct dns_zone *tz = (struct dns_zone *)0; int len; char *tname = (char *)0; isc_result_t status; if (!dns_zone_hash) return ISC_R_NOTFOUND; len = strlen (name); if (name [len - 1] != '.') { tname = dmalloc ((unsigned)len + 2, MDL); if (!tname) return ISC_R_NOMEMORY;; strcpy (tname, name); tname [len] = '.'; tname [len + 1] = 0; name = tname; } if (!dns_zone_hash_lookup (zone, dns_zone_hash, name, 0, MDL)) status = ISC_R_NOTFOUND; else status = ISC_R_SUCCESS; if (tname) dfree (tname, MDL); return status; }
dhcpctl_status dhcpctl_set_callback (dhcpctl_handle h, void *data, void (*func) (dhcpctl_handle, dhcpctl_status, void *)) { dhcpctl_callback_object_t *callback; omapi_object_t *inner; callback = dmalloc (sizeof *callback, MDL); if (!callback) return ISC_R_NOMEMORY; /* Tie the callback object to the innermost object in the chain. */ for (inner = h; inner -> inner; inner = inner -> inner) ; omapi_object_reference (&inner -> inner, (omapi_object_t *)callback, MDL); omapi_object_reference ((omapi_object_t **)&callback -> outer, inner, MDL); /* Save the actual handle pointer we were passed for the callback. */ omapi_object_reference (&callback -> object, h, MDL); callback -> data = data; callback -> callback = func; return ISC_R_SUCCESS; }
extern mtMergeNode mtMergeNode_create (mtMergeClauseList mlist) { mtMergeNode res = (mtMergeNode) dmalloc (sizeof (*res)); res->mlist = mlist; DPRINTF (("merge node: %s", mtMergeNode_unparse (res))); return res; }