([BinaryCStream -decodeValueOfCType:at:withName:]): [_C_CHARPTR]:

Autorelease the malloc'ed char pointer.  Before memory was leaking.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1277 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1996-03-26 22:28:48 +00:00
parent f491e64f1b
commit 23494c1e2f

View file

@ -26,6 +26,7 @@
#include <objects/NSString.h> #include <objects/NSString.h>
#include <objects/StdioStream.h> #include <objects/StdioStream.h>
#include <objects/TextCStream.h> #include <objects/TextCStream.h>
#include <objects/MallocAddress.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#define DEFAULT_FORMAT_VERSION 0 #define DEFAULT_FORMAT_VERSION 0
@ -290,12 +291,13 @@ static BOOL debug_binary_coder;
length: NUM_BYTES_STRING_LENGTH]; length: NUM_BYTES_STRING_LENGTH];
assert (read_count == NUM_BYTES_STRING_LENGTH); assert (read_count == NUM_BYTES_STRING_LENGTH);
length = ntohl (length); length = ntohl (length);
/* xxx Maybe I should make this alloca() instead of malloc(). */
OBJC_MALLOC (*(char**)d, char, length+1); OBJC_MALLOC (*(char**)d, char, length+1);
read_count = [stream readBytes: *(char**)d read_count = [stream readBytes: *(char**)d
length: length]; length: length];
assert (read_count == length); assert (read_count == length);
(*(char**)d)[length] = '\0'; (*(char**)d)[length] = '\0';
/* Autorelease the newly malloc'ed pointer. */
[MallocAddress autoreleaseMallocAddress: *(char**)d];
break; break;
} }