diff options
| -rw-r--r-- | numpy/f2py/cfuncs.py | 4 | ||||
| -rwxr-xr-x | numpy/f2py/rules.py | 2 | ||||
| -rw-r--r-- | numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index de8b0aad5..6b7039436 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -469,7 +469,7 @@ cppmacros['MEMCOPY'] = """\ """ cppmacros['STRINGMALLOC'] = """\ #define STRINGMALLOC(str,len)\\ - if ((str = (string)malloc(sizeof(char)*(len+1))) == NULL) {\\ + if ((str = (string)malloc(len+1)) == NULL) {\\ PyErr_SetString(PyExc_MemoryError, \"out of memory\");\\ goto capi_fail;\\ } else {\\ @@ -492,7 +492,7 @@ STRINGCOPYN copies N bytes. char *_to = (to); \\ char *_from = (from); \\ FAILNULL(_to); FAILNULL(_from); \\ - (void)strncpy(_to, _from, sizeof(char)*_m); \\ + (void)strncpy(_to, _from, _m); \\ } while (0) """ needs['STRINGCOPY'] = ['string.h', 'FAILNULL'] diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index ae0ae684a..16ac68de0 100755 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -561,7 +561,7 @@ rout_rules = [ '\tint #name#_return_value_len = 0;'], 'callfortran':'#name#_return_value,#name#_return_value_len,', 'callfortranroutine':['\t#name#_return_value_len = #rlength#;', - '\tif ((#name#_return_value = (string)malloc(sizeof(char)*(#name#_return_value_len+1))) == NULL) {', + '\tif ((#name#_return_value = (string)malloc(#name#_return_value_len+1)) == NULL) {', '\t\tPyErr_SetString(PyExc_MemoryError, \"out of memory\");', '\t\tf2py_success = 0;', '\t} else {', diff --git a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c index 0411b62e0..fe21d4b9b 100644 --- a/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c +++ b/numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c @@ -93,7 +93,7 @@ static PyObject *f2py_rout_wrap_attrs(PyObject *capi_self, PyObject *strides = NULL; char s[100]; int i; - memset(s,0,100*sizeof(char)); + memset(s,0,100); if (!PyArg_ParseTuple(capi_args,"O!|:wrap.attrs", &PyArray_Type,&arr_capi)) return NULL; |
