mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 10:11:03 +00:00
([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:
parent
f491e64f1b
commit
23494c1e2f
1 changed files with 3 additions and 1 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue