Fix C errors
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10124 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
68f9f87e8d
commit
06e014fdbe
1 changed files with 15 additions and 18 deletions
|
|
@ -121,30 +121,27 @@ SWIG_AsVal_dec(double)(SEXP obj, double *val)
|
|||
SWIGINTERN int
|
||||
SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc)
|
||||
{
|
||||
if (!cptr) return SWIG_TypeError;
|
||||
if (!Rf_isString(obj)) return SWIG_TypeError;
|
||||
const char *cstr;
|
||||
int len;
|
||||
cstr = CHAR(STRING_ELT(obj, 0));
|
||||
len = strlen(cstr);
|
||||
if (cptr && Rf_isString(obj)) {
|
||||
const char *cstr = CHAR(STRING_ELT(obj, 0));
|
||||
int len = strlen(cstr);
|
||||
|
||||
if (cptr) {
|
||||
if (alloc) {
|
||||
if (*alloc == SWIG_NEWOBJ) {
|
||||
*cptr = %new_copy_array(cstr, len + 1, char);
|
||||
*alloc = SWIG_NEWOBJ;
|
||||
} else {
|
||||
*cptr = %reinterpret_cast(malloc(len+1), char *);
|
||||
*cptr = strcpy(*cptr, cstr);
|
||||
*alloc = SWIG_OLDOBJ;
|
||||
}
|
||||
if (alloc) {
|
||||
if (*alloc == SWIG_NEWOBJ) {
|
||||
*cptr = %new_copy_array(cstr, len + 1, char);
|
||||
*alloc = SWIG_NEWOBJ;
|
||||
} else {
|
||||
*cptr = %reinterpret_cast(malloc(len+1), char *);
|
||||
*cptr = strcpy(*cptr, cstr);
|
||||
*cptr = %reinterpret_cast(malloc(len + 1), char *);
|
||||
*cptr = strcpy(*cptr, cstr);
|
||||
*alloc = SWIG_OLDOBJ;
|
||||
}
|
||||
} else {
|
||||
*cptr = %reinterpret_cast(malloc(len + 1), char *);
|
||||
*cptr = strcpy(*cptr, cstr);
|
||||
}
|
||||
if (psize) *psize = len + 1;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue