add ASSIGNMUTABLECOPY

This commit is contained in:
Richard Frith-Macdonald 2020-04-10 11:30:04 +01:00
parent 4ae957746e
commit e95192db5c
2 changed files with 22 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2020-04-10 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/GNUstepBase/GNUstep.h:
Add ASSIGNMUTABLECOPY() macro for consistency with ASSIGNCOPY()
Wolfgang pointed out that the lack of this macro was uninutitive.
2020-04-07 Frederik Seiffert <frederik@algoriddim.com>
* Source/NSOperation.m: Fix completion block memory management.

View file

@ -80,6 +80,9 @@
#ifndef ASSIGNCOPY
#define ASSIGNCOPY(object,value) object = [(value) copy]
#endif
#ifndef ASSIGNMUTABLECOPY
#define ASSIGNMUTABLECOPY(object,value) object = [(value) mutableCopy]
#endif
#ifndef DESTROY
#define DESTROY(object) object = nil
#endif
@ -180,6 +183,19 @@ id __object = (object); (__object != nil) ? [__object autorelease] : nil; })
})
#endif
#ifndef ASSIGNMUTABLECOPY
/**
* ASSIGNMUTABLECOPY(object,value) assigns a mutable copy of the value
* to the object with release of the original.<br />
* Use this to avoid retain/release errors.
*/
#define ASSIGNMUTABLECOPY(object,value) ({\
id __object = object; \
object = [(value) mutableCopy];\
[__object release]; \
})
#endif
#ifndef DESTROY
/**
* DESTROY() is a release operation which also sets the variable to be