stgdict->size = sizeof(void *);
stgdict->align = getentry("P")->pffi_type->alignment;
stgdict->length = 1;
- stgdict->ffi_type = ffi_type_pointer;
+ stgdict->ffi_type_pointer = ffi_type_pointer;
proto = PyDict_GetItemString(typedict, "_type_"); /* Borrowed ref */
if (proto && -1 == PointerType_SetProto(stgdict, proto)) {
stgdict->proto = proto;
/* Arrays are passed as pointers to function calls. */
- stgdict->ffi_type = ffi_type_pointer;
+ stgdict->ffi_type_pointer = ffi_type_pointer;
/* create the new instance (which is a class,
since we are a metatype!) */
if (!stgdict) /* XXX leaks result! */
return NULL;
- stgdict->ffi_type = *fmt->pffi_type;
+ stgdict->ffi_type_pointer = *fmt->pffi_type;
stgdict->align = fmt->pffi_type->alignment;
stgdict->length = 0;
stgdict->size = fmt->pffi_type->size;
fmt = getentry(PyString_AS_STRING(proto));
- stgdict->ffi_type = *fmt->pffi_type;
+ stgdict->ffi_type_pointer = *fmt->pffi_type;
stgdict->align = fmt->pffi_type->alignment;
stgdict->length = 0;
stgdict->size = fmt->pffi_type->size;
stgdict->size = sizeof(void *);
stgdict->setfunc = NULL;
stgdict->getfunc = NULL;
- stgdict->ffi_type = ffi_type_pointer;
+ stgdict->ffi_type_pointer = ffi_type_pointer;
ob = PyDict_GetItemString((PyObject *)stgdict, "_flags_");
if (!ob || !PyInt_Check(ob)) {
StgDictObject *dict = PyObject_stgdict((PyObject *)self);
Py_CLEAR(self->b_objects);
if ((self->b_needsfree)
- && (dict->size > sizeof(self->b_value)))
+ && ((size_t)dict->size > sizeof(self->b_value)))
PyMem_Free(self->b_ptr);
self->b_ptr = NULL;
Py_CLEAR(self->b_base);
static void CData_MallocBuffer(CDataObject *obj, StgDictObject *dict)
{
- if (dict->size <= sizeof(obj->b_value)) {
+ if ((size_t)dict->size <= sizeof(obj->b_value)) {
/* No need to call malloc, can use the default buffer */
obj->b_ptr = (char *)&obj->b_value;
obj->b_needsfree = 1;
/* In python 2.4, and ctypes 0.9.6, the malloc call took about
33% of the creation time for c_int().
*/
- obj->b_ptr = PyMem_Malloc(dict->size);
+ obj->b_ptr = (char *)PyMem_Malloc(dict->size);
obj->b_needsfree = 1;
memset(obj->b_ptr, 0, dict->size);
}
if (!pd)
return NULL;
assert(CDataObject_Check(pd));
- pd->b_ptr = buf;
+ pd->b_ptr = (char *)buf;
pd->b_length = dict->length;
pd->b_size = dict->size;
return (PyObject *)pd;
parg->tag = 'V';
stgdict = PyObject_stgdict((PyObject *)self);
- parg->pffi_type = &stgdict->ffi_type;
+ parg->pffi_type = &stgdict->ffi_type_pointer;
/* For structure parameters (by value), parg->value doesn't contain the structure
data itself, instead parg->value.p *points* to the structure's data
See also _ctypes.c, function _call_function_pointer().
EXPORT(char *) _testfunc_p_p(void *s)
{
- return s;
+ return (char *)s;
}
EXPORT(void *) _testfunc_c_p_p(int *argcp, char **argv)
EXPORT(char *) my_strdup(char *src)
{
- char *dst = malloc(strlen(src)+1);
+ char *dst = (char *)malloc(strlen(src)+1);
if (!dst)
return NULL;
strcpy(dst, src);
EXPORT(wchar_t *) my_wcsdup(wchar_t *src)
{
size_t len = wcslen(src);
- wchar_t *ptr = malloc((len + 1) * sizeof(wchar_t));
+ wchar_t *ptr = (wchar_t *)malloc((len + 1) * sizeof(wchar_t));
if (ptr == NULL)
return NULL;
memcpy(ptr, src, (len+1) * sizeof(wchar_t));
{
static char message[] = "Hello, World";
if (p) {
- *p = malloc(sizeof(char *));
+ *p = (char **)malloc(sizeof(char *));
printf("malloc returned %p\n", *p);
**p = message;
return 1;
if (dict == NULL)
goto error;
p->setfunc = dict->setfunc;
- p->restype = &dict->ffi_type;
+ p->restype = &dict->ffi_type_pointer;
}
cc = FFI_DEFAULT_ABI;
return &ffi_type_sint64;
}
#endif
- return &dict->ffi_type;
+ return &dict->ffi_type_pointer;
}
Py_ssize_t size; /* number of bytes */
Py_ssize_t align; /* alignment requirements */
Py_ssize_t length; /* number of fields */
- ffi_type ffi_type;
+ ffi_type ffi_type_pointer;
PyObject *proto; /* Only for Pointer/ArrayObject */
SETFUNC setfunc; /* Only for simple objects */
GETFUNC getfunc; /* Only for simple objects */
StgDict_dealloc(StgDictObject *self)
{
StgDict_clear(self);
- PyMem_Free(self->ffi_type.elements);
+ PyMem_Free(self->ffi_type_pointer.elements);
PyDict_Type.tp_dealloc((PyObject *)self);
}
int size;
StgDict_clear(dst);
- PyMem_Free(dst->ffi_type.elements);
- dst->ffi_type.elements = NULL;
+ PyMem_Free(dst->ffi_type_pointer.elements);
+ dst->ffi_type_pointer.elements = NULL;
d = (char *)dst;
s = (char *)src;
Py_XINCREF(dst->restype);
Py_XINCREF(dst->checker);
- if (src->ffi_type.elements == NULL)
+ if (src->ffi_type_pointer.elements == NULL)
return 0;
size = sizeof(ffi_type *) * (src->length + 1);
- dst->ffi_type.elements = PyMem_Malloc(size);
- if (dst->ffi_type.elements == NULL)
+ dst->ffi_type_pointer.elements = PyMem_Malloc(size);
+ if (dst->ffi_type_pointer.elements == NULL)
return -1;
- memcpy(dst->ffi_type.elements, src->ffi_type.elements, size);
+ memcpy(dst->ffi_type_pointer.elements,
+ src->ffi_type_pointer.elements,
+ size);
return 0;
}
stuff is sucessfully finished. */
stgdict->flags |= DICTFLAG_FINAL; /* set final */
- if (stgdict->ffi_type.elements)
- PyMem_Free(stgdict->ffi_type.elements);
+ if (stgdict->ffi_type_pointer.elements)
+ PyMem_Free(stgdict->ffi_type_pointer.elements);
basedict = PyType_stgdict((PyObject *)((PyTypeObject *)type)->tp_base);
if (basedict && !use_broken_old_ctypes_semantics) {
align = basedict->align;
union_size = 0;
total_align = align ? align : 1;
- stgdict->ffi_type.type = FFI_TYPE_STRUCT;
- stgdict->ffi_type.elements = PyMem_Malloc(sizeof(ffi_type *) * (basedict->length + len + 1));
- memset(stgdict->ffi_type.elements, 0, sizeof(ffi_type *) * (basedict->length + len + 1));
- memcpy(stgdict->ffi_type.elements, basedict->ffi_type.elements,
+ stgdict->ffi_type_pointer.type = FFI_TYPE_STRUCT;
+ stgdict->ffi_type_pointer.elements = PyMem_Malloc(sizeof(ffi_type *) * (basedict->length + len + 1));
+ memset(stgdict->ffi_type_pointer.elements, 0,
+ sizeof(ffi_type *) * (basedict->length + len + 1));
+ memcpy(stgdict->ffi_type_pointer.elements,
+ basedict->ffi_type_pointer.elements,
sizeof(ffi_type *) * (basedict->length));
ffi_ofs = basedict->length;
} else {
align = 0;
union_size = 0;
total_align = 1;
- stgdict->ffi_type.type = FFI_TYPE_STRUCT;
- stgdict->ffi_type.elements = PyMem_Malloc(sizeof(ffi_type *) * (len + 1));
- memset(stgdict->ffi_type.elements, 0, sizeof(ffi_type *) * (len + 1));
+ stgdict->ffi_type_pointer.type = FFI_TYPE_STRUCT;
+ stgdict->ffi_type_pointer.elements = PyMem_Malloc(sizeof(ffi_type *) * (len + 1));
+ memset(stgdict->ffi_type_pointer.elements, 0,
+ sizeof(ffi_type *) * (len + 1));
ffi_ofs = 0;
}
i);
return -1;
}
- stgdict->ffi_type.elements[ffi_ofs + i] = &dict->ffi_type;
+ stgdict->ffi_type_pointer.elements[ffi_ofs + i] = &dict->ffi_type_pointer;
dict->flags |= DICTFLAG_FINAL; /* mark field type final */
if (PyTuple_Size(pair) == 3) { /* bits specified */
- switch(dict->ffi_type.type) {
+ switch(dict->ffi_type_pointer.type) {
case FFI_TYPE_UINT8:
case FFI_TYPE_UINT16:
case FFI_TYPE_UINT32:
/* Adjust the size according to the alignment requirements */
size = ((size + total_align - 1) / total_align) * total_align;
- stgdict->ffi_type.alignment = total_align;
- stgdict->ffi_type.size = size;
+ stgdict->ffi_type_pointer.alignment = total_align;
+ stgdict->ffi_type_pointer.size = size;
stgdict->size = size;
stgdict->align = total_align;