mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
set 'free' flag for inline strings and comment it
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22969 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8ad89b9941
commit
2dbae8ac85
2 changed files with 23 additions and 19 deletions
|
@ -1,9 +1,12 @@
|
|||
2006-05-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
Fix longstanding NSSerialiser deserialisation problem ... is not
|
||||
retaining cross-referenced items... which is not a problem unless
|
||||
* Source/NSSerializer.m: Fix longstanding deserialisation problem ...
|
||||
is not retaining cross-referenced items... which is not a problem unless
|
||||
the item happens to be a dictionary key which is copied/released
|
||||
when the corresponding value is added to the dictionary.
|
||||
* Source/GSString.m: Make sure inline strings have 'free' flag set and
|
||||
add comments to say we use it to indicate ownership of buffer rather
|
||||
than whether to free the data. Maybe we should change the flag name?
|
||||
|
||||
2006-05-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -572,7 +573,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
|
|||
me->_contents.c = (unsigned char*)&((GSCInlineString*)me)[1];
|
||||
me->_count = length;
|
||||
me->_flags.wide = 0;
|
||||
me->_flags.free = 0;
|
||||
me->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
while (length-- > 0)
|
||||
{
|
||||
me->_contents.c[length] = ((unichar*)chars)[length];
|
||||
|
@ -687,7 +688,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
|
|||
me->_contents.u = (unichar*)&((GSUnicodeInlineString*)me)[1];
|
||||
me->_count = f._count;
|
||||
me->_flags.wide = 1;
|
||||
me->_flags.free = 1;
|
||||
me->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
memcpy(me->_contents.u, f._contents.u, f._count*sizeof(unichar));
|
||||
}
|
||||
else
|
||||
|
@ -697,7 +698,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
|
|||
me->_contents.c = (unsigned char*)&((GSCInlineString*)me)[1];
|
||||
me->_count = f._count;
|
||||
me->_flags.wide = 0;
|
||||
me->_flags.free = 1;
|
||||
me->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
memcpy(me->_contents.c, f._contents.c, f._count);
|
||||
}
|
||||
|
||||
|
@ -744,7 +745,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
|
|||
me->_contents.c = (unsigned char*)&((GSCInlineString*)me)[1];
|
||||
me->_count = length;
|
||||
me->_flags.wide = 0;
|
||||
me->_flags.free = 1;
|
||||
me->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
memcpy(me->_contents.c, ((GSStr)string)->_contents.c, length);
|
||||
}
|
||||
else if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES
|
||||
|
@ -759,7 +760,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
|
|||
me->_contents.u = (unichar*)&((GSUnicodeInlineString*)me)[1];
|
||||
me->_count = length;
|
||||
me->_flags.wide = 1;
|
||||
me->_flags.free = 1;
|
||||
me->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
memcpy(me->_contents.u, ((GSStr)string)->_contents.u,
|
||||
length*sizeof(unichar));
|
||||
}
|
||||
|
@ -774,7 +775,7 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
|
|||
me->_contents.u = (unichar*)&((GSUnicodeInlineString*)me)[1];
|
||||
me->_count = length;
|
||||
me->_flags.wide = 1;
|
||||
me->_flags.free = 1;
|
||||
me->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
[string getCharacters: me->_contents.u];
|
||||
}
|
||||
return (id)me;
|
||||
|
@ -2920,7 +2921,7 @@ agree, create a new GSCInlineString otherwise.
|
|||
o->_count = _count;
|
||||
memcpy(o->_contents.c, _contents.c, _count);
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.free = 0;
|
||||
o->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
return (id)o;
|
||||
}
|
||||
else
|
||||
|
@ -2972,7 +2973,7 @@ agree, create a new GSCInlineString otherwise.
|
|||
o->_count = _count;
|
||||
memcpy(o->_contents.c, _contents.c, _count);
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.free = 0;
|
||||
o->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
return (id)o;
|
||||
}
|
||||
|
||||
|
@ -3231,7 +3232,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
o->_count = _count;
|
||||
memcpy(o->_contents.u, _contents.u, _count * sizeof(unichar));
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.free = 0;
|
||||
o->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
return (id)o;
|
||||
}
|
||||
else
|
||||
|
@ -3284,7 +3285,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
o->_count = _count;
|
||||
memcpy(o->_contents.u, _contents.u, _count * sizeof(unichar));
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.free = 0;
|
||||
o->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
return (id)o;
|
||||
}
|
||||
|
||||
|
@ -3403,7 +3404,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
o->_count = _count;
|
||||
memcpy(o->_contents.u, _contents.u, _count * sizeof(unichar));
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.free = 0;
|
||||
o->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
return (id)o;
|
||||
}
|
||||
else
|
||||
|
@ -3417,7 +3418,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
o->_count = _count;
|
||||
memcpy(o->_contents.c, _contents.c, _count);
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.free = 0;
|
||||
o->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
return (id)o;
|
||||
}
|
||||
}
|
||||
|
@ -4139,7 +4140,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
memcpy(o->_contents.u, _contents.u + aRange.location,
|
||||
aRange.length * sizeof(unichar));
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.free = 0;
|
||||
o->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
return AUTORELEASE((id)o);
|
||||
}
|
||||
else
|
||||
|
@ -4154,7 +4155,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
o->_count = aRange.length;
|
||||
memcpy(o->_contents.c, _contents.c + aRange.location, aRange.length);
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.free = 0;
|
||||
o->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
return AUTORELEASE((id)o);
|
||||
}
|
||||
}
|
||||
|
@ -4176,7 +4177,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
memcpy(o->_contents.u, _contents.u + aRange.location,
|
||||
aRange.length * sizeof(unichar));
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.free = 0;
|
||||
o->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
return AUTORELEASE((id)o);
|
||||
}
|
||||
else
|
||||
|
@ -4191,7 +4192,7 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
o->_count = aRange.length;
|
||||
memcpy(o->_contents.c, _contents.c + aRange.location, aRange.length);
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.free = 0;
|
||||
o->_flags.free = 1; // Ignored on dealloc, but means we own buffer
|
||||
return AUTORELEASE((id)o);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue