Fix sizing structures in cifframe

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14437 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2002-09-13 21:56:09 +00:00
parent 7cf7efc9b1
commit 33589dec57
3 changed files with 13 additions and 4 deletions

View file

@ -1,3 +1,10 @@
2002-09-13 Adam Fedor <fedor@gnu.org>
* Source/cifframe.m (cifframe_guess_struct_size): Recurse if
element contains structures.
(cifframe_from_info): Alloc room for return value even if caller
doesn't use it.
Thu Sep 12 11:02:03 2002 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSObject.m ([+_becomeMultiThreaded:]): Fixed typo - this

View file

@ -95,7 +95,6 @@
#include <Foundation/NSZone.h>
#include <Foundation/NSLock.h>
/*
* Try to get more memory - the normal process has failed.
* If we can't do anything, bomb out.

View file

@ -100,7 +100,10 @@ cifframe_guess_struct_size(ffi_type *stype)
i = 0;
while (stype->elements[i])
{
size += stype->elements[i]->size;
if (stype->elements[i]->elements)
size += cifframe_guess_struct_size(stype->elements[i]);
else
size += stype->elements[i]->size;
if (size % align != 0)
{
@ -173,7 +176,7 @@ cifframe_from_info (NSArgumentInfo *info, int numargs, void **retval)
* make room for it at the end of the cifframe so we
* only need to do a single malloc.
*/
if (retval)
if (rtype && rtype->size > 0)
{
unsigned full = size;
unsigned pos;
@ -188,7 +191,7 @@ cifframe_from_info (NSArgumentInfo *info, int numargs, void **retval)
else
full += MAX(rtype->size, sizeof(smallret_t));
cframe = buf = NSZoneCalloc(NSDefaultMallocZone(), full, 1);
if (cframe)
if (cframe && retval)
{
*retval = buf + pos;
}