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:
William S Fulton 2007-11-14 21:47:44 +00:00
commit 06e014fdbe

View file

@ -121,14 +121,10 @@ SWIG_AsVal_dec(double)(SEXP obj, double *val)
SWIGINTERN int SWIGINTERN int
SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc) SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc)
{ {
if (!cptr) return SWIG_TypeError; if (cptr && Rf_isString(obj)) {
if (!Rf_isString(obj)) return SWIG_TypeError; const char *cstr = CHAR(STRING_ELT(obj, 0));
const char *cstr; int len = strlen(cstr);
int len;
cstr = CHAR(STRING_ELT(obj, 0));
len = strlen(cstr);
if (cptr) {
if (alloc) { if (alloc) {
if (*alloc == SWIG_NEWOBJ) { if (*alloc == SWIG_NEWOBJ) {
*cptr = %new_copy_array(cstr, len + 1, char); *cptr = %new_copy_array(cstr, len + 1, char);
@ -142,10 +138,11 @@ SWIG_AsCharPtrAndSize(SEXP obj, char** cptr, size_t* psize, int *alloc)
*cptr = %reinterpret_cast(malloc(len + 1), char *); *cptr = %reinterpret_cast(malloc(len + 1), char *);
*cptr = strcpy(*cptr, cstr); *cptr = strcpy(*cptr, cstr);
} }
}
if (psize) *psize = len + 1; if (psize) *psize = len + 1;
return SWIG_OK; return SWIG_OK;
} }
return SWIG_TypeError;
}
} }
%fragment("SWIG_strdup","header") %fragment("SWIG_strdup","header")