Lines Matching defs:sg
89 StringGroup *sg; /* The object to be returned */
100 sg = (StringGroup *) malloc(sizeof(StringGroup));
101 if(!sg) {
110 sg->node_mem = NULL;
111 sg->head = NULL;
112 sg->block_size = segment_size;
116 sg->node_mem = _new_FreeList(sizeof(StringSegment), STR_SEG_BLK);
117 if(!sg->node_mem)
118 return _del_StringGroup(sg);
119 return sg;
126 * sg StringGroup * The object to be deleted.
130 StringGroup *_del_StringGroup(StringGroup *sg)
132 if(sg) {
137 for(node=sg->head; node; node=node->next) {
145 sg->node_mem = _del_FreeList(sg->node_mem, 1);
146 sg->head = NULL; /* Already deleted by deleting sg->node_mem */
150 free(sg);
160 * sg StringGroup * The group to store the string in.
168 char *_sg_store_string(StringGroup *sg, const char *string, int remove_escapes)
175 if(!sg || !string)
181 copy = _sg_alloc_string(sg, len);
222 * sg StringGroup * The group to store the string in.
228 char *_sg_alloc_string(StringGroup *sg, int length)
235 if(length > sg->block_size || length < 0)
242 for(node=sg->head; node && node->unused <= length; node=node->next)
248 node = (StringSegment *) _new_FreeListNode(sg->node_mem);
256 node->unused = sg->block_size;
260 node->block = (char *) malloc(sg->block_size);
266 node->next = sg->head;
267 sg->head = node;
272 copy = node->block + sg->block_size - node->unused;
285 * sg StringGroup * The group of strings to clear.
287 void _clr_StringGroup(StringGroup *sg)
293 for(node=sg->head; node; node=node->next)
294 node->unused = sg->block_size;