コード例 #1
0
ファイル: nrnjni.cpp プロジェクト: stephanmg/neuron
JNIEXPORT void JNICALL Java_neuron_Neuron_pushArgS
  (JNIEnv *env, jclass, jstring js){
	// see java2nrn_smeth for a similar implementation
	// hopefully 20 is sufficient before a string is freed.
	// perhaps a more general implementation is needed.
	// It would be safe to free these when the corresponding
	// hCharsMethod call returns.
	static char** cs;
	static int i;
#define ncs 20
	const char* jc = env->GetStringUTFChars(js, 0);
	if (!cs) {
		cs = new char*[ncs];
		for (i=0; i < ncs; ++i) {
			cs[i] = nil;
		}
		i = 0;
	}
	if (cs[i]) {
		delete [] cs[i];
	}
	i = (i+1)%ncs;
	cs[i] = new char[strlen(jc + 1)];
	strcpy(cs[i], jc);
	hoc_pushstr(cs + i);
//printf("pushArgS |%s|\n", cs[i]);
	env->ReleaseStringUTFChars(js, jc);
}
コード例 #2
0
ファイル: nocable.c プロジェクト: vortexlaboratory/neuron
void hoc_secname(void) {
	hoc_ret();
	pdummystring = dummystring;
	hoc_pushstr(&pdummystring);
}