void Command_free(T *C) { assert(C && *C); freeStrings((*C)->args); List_free(&(*C)->args); freeStrings((*C)->env); List_free(&(*C)->env); FREE((*C)->working_directory); FREE(*C); }
ItemAttributes& ItemAttributes::operator=( const std::pair< OPCHANDLE, GroupItemElem >& newItem ) { freeStrings(); os::win32::com::zeroMemory( attributes ); attributes->hServer = newItem.first; attributes->bActive = newItem.second->isActived(); attributes->hClient = newItem.second->getClientHandle(); #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) attributes->szItemID = util::duplicateString( newItem.second->getItemID() ); #else attributes->szItemID = util::duplicateString( string2wstring( newItem.second->getItemID() ) ); #endif #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) attributes->szAccessPath = util::duplicateString( newItem.second->getAccessPath() ); #else attributes->szAccessPath = util::duplicateString( string2wstring( newItem.second->getAccessPath() ) ); #endif address_space::Tag *item = opcAddressSpace::getInstance().getTag( newItem.second->getItemID() ); attributes->dwAccessRights = item->getAccessRights(); attributes->dwBlobSize = 0; attributes->pBlob = NULL; attributes->vtCanonicalDataType = item->getCanonicalDataType(); attributes->vtRequestedDataType = newItem.second->getReguestDataType(); return *this; }
/* Build the Command args list. The list represent the array sent to execv and the List contains the following entries: args[0] is the path to the program, the rest are arguments to the program */ static void buildArgs(T C, const char *path, const char *x, va_list ap) { freeStrings(C->args); List_append(C->args, Str_dup(path)); va_list ap_copy; va_copy(ap_copy, ap); for (; x; x = va_arg(ap_copy, char *)) List_append(C->args, Str_dup(x)); va_end(ap_copy); }
/** * Converts Java String[] to char** and delegates to executeProcess(). */ static pid_t ProcessManager_exec( JNIEnv* env, jclass, jobjectArray javaCommands, jobjectArray javaEnvironment, jstring javaWorkingDirectory, jobject inDescriptor, jobject outDescriptor, jobject errDescriptor, jboolean redirectErrorStream) { // Copy commands into char*[]. char** commands = convertStrings(env, javaCommands); // Extract working directory string. const char* workingDirectory = NULL; if (javaWorkingDirectory != NULL) { workingDirectory = env->GetStringUTFChars(javaWorkingDirectory, NULL); } // Convert environment array. char** environment = convertStrings(env, javaEnvironment); pid_t result = executeProcess( env, commands, environment, workingDirectory, inDescriptor, outDescriptor, errDescriptor, redirectErrorStream); // Temporarily clear exception so we can clean up. jthrowable exception = env->ExceptionOccurred(); env->ExceptionClear(); freeStrings(env, javaEnvironment, environment); // Clean up working directory string. if (javaWorkingDirectory != NULL) { env->ReleaseStringUTFChars(javaWorkingDirectory, workingDirectory); } freeStrings(env, javaCommands, commands); // Re-throw exception if present. if (exception != NULL) { if (env->Throw(exception) < 0) { LOGE("Error rethrowing exception!"); } } return result; }
void p(cspider_t *cspider, char *d, char *url, void *user_data) { char *get[10]; int size = xpath(d, "//a/@href", get, 10); // int size = regexAll("http:\\/\\/(.*?)\\.html", d, get, 3, REGEX_ALL); cspider_joinall(url,get,size); addUrls(cspider, get, size); saveStrings(cspider, (void**)get, size, LOCK); freeStrings(get, size); }
ItemAttributes& ItemAttributes::operator=( const ItemAttributes& rhv ) { if( this == &rhv ) return *this; freeStrings(); os::win32::com::zeroMemory( attributes ); attributes->bActive = rhv.attributes->bActive; attributes->dwAccessRights = rhv.attributes->dwAccessRights; attributes->dwBlobSize = rhv.attributes->dwBlobSize; attributes->dwEUType = rhv.attributes->dwEUType; attributes->hClient = rhv.attributes->hClient; attributes->hServer = rhv.attributes->hServer; attributes->pBlob = rhv.attributes->pBlob; attributes->szAccessPath = util::duplicateString( rhv.attributes->szAccessPath ); attributes->szItemID = util::duplicateString( rhv.attributes->szItemID ); VariantCopy( &attributes->vEUInfo , &rhv.attributes->vEUInfo ); attributes->vtCanonicalDataType = rhv.attributes->vtCanonicalDataType; attributes->vtRequestedDataType = rhv.attributes->vtRequestedDataType; return *this; }
void freeRequestData(int requestId, void *data, size_t datalen) { CommandInfo *ci = &s_commandInfo[requestId]; if (ci->dispatchFunction == dispatchInts || ci->dispatchFunction == dispatchRaw || ci->dispatchFunction == dispatchString) { if (data) free(data); } else if (ci->dispatchFunction == dispatchStrings) { freeStrings(data, datalen); } else if (ci->dispatchFunction == dispatchSIM_IO) { freeSIM_IO(data); } else if (ci->dispatchFunction == dispatchDial) { freeDial(data); } else if (ci->dispatchFunction == dispatchVoid) { } else if (ci->dispatchFunction == dispatchCallForward) { freeCallForward(data); } else if (ci->dispatchFunction == dispatchSmsWrite) { freeSmsWrite(data); } else if (ci->dispatchFunction == dispatchGsmBrSmsCnf) { freeGsmBrSmsCnf(data, datalen); } }
ItemAttributes::~ItemAttributes() { freeStrings(); VariantClear( &attributes->vEUInfo ); os::win32::com::freeMemory( attributes ); }
void filesbokCB(Widget widget, Exc_data * ed, XtPointer call_data) { XmFileSelectionBoxCallbackStruct *ptr; char *file = NULL, *dir = NULL, *tmpfile; int r, ans = 0; char *msg1; char *msg2; msg1 = GETMESSAGE(2, 4, "The selected file exists. Overwrite?"); msg2 = GETMESSAGE(2, 6, "Failed to open the selected file."); ptr = (XmFileSelectionBoxCallbackStruct *) call_data; file = (char *) _XmStringUngenerate((XmString) ptr->value, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); if (!file) { return; } dir = (char *) _XmStringUngenerate((XmString) ptr->dir, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT); if (!dir) { return; } else { if (*file != '/') { if ((tmpfile = XtMalloc(strlen(dir) + 1 + strlen(file) + 1)) == NULL) { excerror(ed, EXCERRMALLOC, "filesbokCB", "exit"); } sprintf(tmpfile, "%s/%s", dir, file); XtFree(file); file = tmpfile; } } r = fopencheck(file, dir, ed->bdfmode); if (r == 0) {/* no problem */ /*fprintf(stderr, "%s will be opened\n", file);*/ } else if (r == 1) { /* file exist at export function */ AskUser(widget, ed, msg1, &ans, "warning"); if (ans != 1) { /* overwrite cancel */ freeStrings(dir, file); return; } } else { /* file will not be opened */ AskUser(widget, ed, msg2, &ans, "error"); freeStrings(dir, file); return; } ed->bdffile = (char *) malloc(strlen(file) + 1); strcpy(ed->bdffile, file); freeStrings(dir, file); XtUnmanageChild(widget); if (ed->function == EXPORT) { createbdf(ed); } else if (ed->function == IMPORT) { PopupSelectXLFD(ed->toplevel); } }