Eliminate some temporary buffers
This commit is contained in:
parent
b5dbcb4ece
commit
5755f399a2
3 changed files with 6 additions and 25 deletions
|
|
@ -981,27 +981,14 @@ String *CFFI::lispify_name(Node *n, String *ty, const char *flag, bool kw) {
|
||||||
/* utilities */
|
/* utilities */
|
||||||
/* returns new string w/ parens stripped */
|
/* returns new string w/ parens stripped */
|
||||||
String *CFFI::strip_parens(String *string) {
|
String *CFFI::strip_parens(String *string) {
|
||||||
char *s = Char(string), *p;
|
char *s = Char(string);
|
||||||
int len = Len(string);
|
int len = Len(string);
|
||||||
String *res;
|
|
||||||
|
|
||||||
if (len == 0 || s[0] != '(' || s[len - 1] != ')') {
|
if (len == 0 || s[0] != '(' || s[len - 1] != ')') {
|
||||||
return NewString(string);
|
return NewString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
p = (char *) malloc(len - 2 + 1);
|
return NewStringWithSize(s + 1, len - 2);
|
||||||
if (!p) {
|
|
||||||
Printf(stderr, "Malloc failed\n");
|
|
||||||
SWIG_exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(p, s + 1, len - 1);
|
|
||||||
p[len - 2] = 0; /* null terminate */
|
|
||||||
|
|
||||||
res = NewString(p);
|
|
||||||
free(p);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String *CFFI::trim(String *str) {
|
String *CFFI::trim(String *str) {
|
||||||
|
|
|
||||||
|
|
@ -947,20 +947,16 @@ public:
|
||||||
|
|
||||||
if (!is_setter) {
|
if (!is_setter) {
|
||||||
/* Strip off "-get" */
|
/* Strip off "-get" */
|
||||||
char *pws_name = (char *) malloc(sizeof(char) * (len - 3));
|
|
||||||
strncpy(pws_name, pc, len - 3);
|
|
||||||
pws_name[len - 4] = 0;
|
|
||||||
if (struct_member == 2) {
|
if (struct_member == 2) {
|
||||||
/* There was a setter, so create a procedure with setter */
|
/* There was a setter, so create a procedure with setter */
|
||||||
Printf(f_init, "scm_c_define");
|
Printf(f_init, "scm_c_define");
|
||||||
Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(getter, setter));\n", pws_name);
|
Printf(f_init, "(\"%.*s\", " "scm_make_procedure_with_setter(getter, setter));\n", pc, len - 4);
|
||||||
} else {
|
} else {
|
||||||
/* There was no setter, so make an alias to the getter */
|
/* There was no setter, so make an alias to the getter */
|
||||||
Printf(f_init, "scm_c_define");
|
Printf(f_init, "scm_c_define");
|
||||||
Printf(f_init, "(\"%s\", getter);\n", pws_name);
|
Printf(f_init, "(\"%.*s\", getter);\n", pc, len - 4);
|
||||||
}
|
}
|
||||||
Printf(exported_symbols, "\"%s\", ", pws_name);
|
Printf(exported_symbols, "\"%.*s\", ", pc, len - 4);
|
||||||
free(pws_name);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Register the function */
|
/* Register the function */
|
||||||
|
|
|
||||||
|
|
@ -471,9 +471,7 @@ static void getoptions(int argc, char *argv[]) {
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strncmp(argv[i], "-I", 2) == 0) {
|
} else if (strncmp(argv[i], "-I", 2) == 0) {
|
||||||
// Add a new directory search path
|
// Add a new directory search path
|
||||||
char *a = Swig_copy_string(argv[i] + 2);
|
Swig_add_directory((String_or_char*)(argv[i] + 2));
|
||||||
Swig_add_directory((DOH *) a);
|
|
||||||
free(a);
|
|
||||||
Swig_mark_arg(i);
|
Swig_mark_arg(i);
|
||||||
} else if (strncmp(argv[i], "-D", 2) == 0) {
|
} else if (strncmp(argv[i], "-D", 2) == 0) {
|
||||||
String *d = NewString(argv[i] + 2);
|
String *d = NewString(argv[i] + 2);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue