File: delete-string.2gg

package info (click to toggle)
golf 601.4.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,824 kB
  • sloc: ansic: 20,020; sh: 1,171; makefile: 292
file content (73 lines) | stat: -rw-r--r-- 1,596 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
delete-string \-  (strings)
.SH PURPOSE
Free string memory.

.SH SYNTAX

.RS 4
.EX

delete-string <string> 

.EE
.RE

.SH DESCRIPTION
delete-string frees <string> variable previously allocated by a Golf statement. 

Note that freeing memory is in most cases unnecessary as Golf will automatically do so at the end of each request. You should have a good reason for using delete-string otherwise.

Golf keeps count of <string> references for process-scoped memory (see \fBmemory-handling\fP), and such memory will be deleted at the end of the request once reference count reaches zero. 

For non-process-scoped memory, if <string> is referenced by other variables, then <string> may not be deleted. Regardless of whether the memory referenced by <string> is actually deleted or not, <string> becomes an empty string ("") after delete-string.

.SH EXAMPLES
Allocate and free random string:

.RS 4
.EX

random-string to ran_str
\[char46]..
delete-string ran_str

.EE
.RE

Free string allocated by write-string (consisting of 100 "Hello World"s):

.RS 4
.EX

write-string ws
    start-loop repeat 100
        @Hello World
    end-loop
end-write-string
\[char46]..
delete-string ws 

.EE
.RE

.SH SEE ALSO
 Strings

\fBconcatenate-strings\fP  
\fBcopy-string\fP  
\fBcount-substring\fP  
\fBdelete-string\fP  
\fBlower-string\fP  
\fBnew-string\fP  
\fBread-split\fP  
\fBreplace-string\fP  
\fBset-string\fP  
\fBsplit-string\fP  
\fBstring-length\fP  
\fBtrim-string\fP  
\fBupper-string\fP  
\fBwrite-string\fP   
See all 
\fBdocumentation\fP