On Sat, Sep 14, 2013 at 12:29 PM, <[email protected]> wrote: > Const 'ptr' instance variable of String
> Project: http://git-wip-us.apache.org/repos/asf/lucy/repo > Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/fc363f05 > Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/fc363f05 > Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/fc363f05 > /** Return a new String which holds a copy of the passed-in string. > * Check for UTF-8 validity. > @@ -48,19 +48,19 @@ class Clownfish::String cnick Str > * passed-in string. Check validity of supplied UTF-8. > */ > inert incremented String* > - new_steal_str(char *ptr, size_t size); > + new_steal_str(const char *ptr, size_t size); > > /** Return a pointer to a new String which assumes ownership of the > * passed-in string. Do not check validity of supplied UTF-8. > */ > inert incremented String* > - new_steal_from_trusted_str(char *ptr, size_t size); > + new_steal_from_trusted_str(const char *ptr, size_t size); > > /** Initialize the String using the passed-in string. Do not check > * validity of supplied UTF-8. > */ > public inert String* > - init_steal_trusted_str(decremented String *self, char *ptr, size_t size); > + init_steal_trusted_str(String *self, const char *ptr, size_t size); > > /** Return a String which holds a single character. It seems to me that the "steal" constructors should take `char*` instead of `const char*`. We have to cast away constness in the destructor when we invoke "free" on the stolen strings, right? The potential exists to create a situation where we free() non-heap memory and the compiler doesn't issue a warning. Marvin Humphrey
