48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
end
terra ty:pdup(p: &lib.mem.pool): strptr
if not @self then return strptr.null() end
if self.ct == 0 then self.ct = m.sz(self.ptr) end
var newstr = p:alloc(int8, self.ct)
lib.mem.cpy(newstr.ptr, self.ptr, self.ct)
return newstr
end
terra ty:cmp(other: ty)
if self.ptr == nil and other.ptr == nil then return true end
if self.ptr == nil or other.ptr == nil then return false end
var sz = lib.math.biggest(self.ct, other.ct)
for i = 0, sz do
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
end
terra ty:pdup(p: &lib.mem.pool): strptr
if not @self then return strptr.null() end
if self.ct == 0 then self.ct = m.sz(self.ptr) end
var newstr = p:alloc(int8, self.ct)
lib.mem.cpy(newstr.ptr, self.ptr, self.ct)
return newstr
end
terra ty:pcdup(p: &lib.mem.pool): rawstring
if not @self then return nil end
if self.ct == 0 then self.ct = m.sz(self.ptr) end
var newstr = p:alloc(int8, self.ct + 1)
lib.mem.cpy(newstr.ptr, self.ptr, self.ct)
newstr.ptr[self.ct] = 0
return newstr.ptr
end
terra ty:cdup(): rawstring
if not @self then return nil end
if self.ct == 0 then self.ct = m.sz(self.ptr) end
var newstr = lib.mem.heapa(int8, self.ct + 1)
lib.mem.cpy(newstr.ptr, self.ptr, self.ct)
newstr.ptr[self.ct] = 0
return newstr.ptr
end
terra ty:cmp(other: ty)
if self.ptr == nil and other.ptr == nil then return true end
if self.ptr == nil or other.ptr == nil then return false end
var sz = lib.math.biggest(self.ct, other.ct)
for i = 0, sz do
|