Check-in [56c0612e71]
Overview
SHA1:56c0612e71661df93ce12b73247697c8e78bc55a
Date: 2014-11-14 21:43:47
User: rkeene
Comment:Corrected memory leaks in CVFS
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2014-11-17
18:43
[dfa8940a62] Updated order of Incr/Decr in CVFS for consistency (user: rkeene, tags: trunk)
2014-11-14
21:43
[56c0612e71] Corrected memory leaks in CVFS (user: rkeene, tags: trunk)
2014-11-13
18:03
[02c667ab97] Updated 8.6 builds to 8.6.3 (user: rkeene, tags: trunk)
Changes

Modified kitsh/buildsrc/kitsh-0.0/cvfs_data.c from [dcf0f1a5fd] to [2f0d8b57ce].

16
17
18
19
20
21
22

23
24
25
26
27
28
29
..
81
82
83
84
85
86
87
88




89
90






91


92
93
94
95
96
97
98
...
175
176
177
178
179
180
181
182


183


184
185
186
187
188
189
190
...
239
240
241
242
243
244
245


246
247
248
249
250
251
252
...
254
255
256
257
258
259
260
261


262


263
264
265
266
267


268
269
270
	cmd_getData_t *cmd_getData;
	cmd_getChildren_t *cmd_getChildren;
	struct cvfs_data *finfo = NULL;
	Tcl_Obj *ret_list, *ret_list_items[20];
	unsigned long num_children;
	const char *hashkey;
	const char *file;


	if (objc != 3) {
		Tcl_SetResult(interp, "wrong # args: should be \"getMetadata hashKey fileName\"", TCL_STATIC);

		return(TCL_ERROR);
	}

................................................................................
	ret_list_items[15] = Tcl_NewStringObj("0", 1);

	ret_list_items[16] = Tcl_NewStringObj("mtime", 5);
	ret_list_items[17] = Tcl_NewStringObj("0", 1);

	ret_list_items[18] = Tcl_NewStringObj("ctime", 5);
	ret_list_items[19] = Tcl_NewStringObj("0", 1);





	ret_list = Tcl_NewListObj(sizeof(ret_list_items) / sizeof(ret_list_items[0]), ret_list_items);







	Tcl_SetObjResult(interp, ret_list);



	return(TCL_OK);
}

static int getData(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
	struct cvfs_data *finfo = NULL;
	cmd_getData_t *cmd_getData;
................................................................................
	if (end < start) {
		Tcl_SetResult(interp, "Invalid arguments, start must be less than end", TCL_STATIC);

		return(TCL_ERROR);
	}

	ret_str = Tcl_NewByteArrayObj(finfo->data + start, (end - start));



	Tcl_SetObjResult(interp, ret_str);



	return(TCL_OK);
}

static int getChildren(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
	struct cvfs_data *finfo = NULL;
	cmd_getChildren_t *cmd_getChildren;
................................................................................

	ret_list = Tcl_NewObj();
	if (ret_list == NULL) {
		Tcl_SetResult(interp, "Failed to allocate new object", TCL_STATIC);

		return(TCL_ERROR);
	}



	children = malloc(sizeof(*children) * num_children);

	num_children = cmd_getChildren(file, children, num_children);

	for (idx = 0; idx < num_children; idx++) {
		finfo = cmd_getData(NULL, children[idx]);
................................................................................
		if (finfo == NULL || finfo->name == NULL) {
			continue;
		}

		child = finfo->name;

		ret_curr_obj = Tcl_NewStringObj(child, strlen(child));



		Tcl_ListObjAppendList(interp, ret_list, ret_curr_obj);


	}

	free(children);

	Tcl_SetObjResult(interp, ret_list);



	return(TCL_OK);
}







>







 








>
>
>
>


>
>
>
>
>
>

>
>







 








>
>

>
>







 







>
>







 








>
>

>
>





>
>



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
..
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
...
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
...
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
	cmd_getData_t *cmd_getData;
	cmd_getChildren_t *cmd_getChildren;
	struct cvfs_data *finfo = NULL;
	Tcl_Obj *ret_list, *ret_list_items[20];
	unsigned long num_children;
	const char *hashkey;
	const char *file;
	int idx;

	if (objc != 3) {
		Tcl_SetResult(interp, "wrong # args: should be \"getMetadata hashKey fileName\"", TCL_STATIC);

		return(TCL_ERROR);
	}

................................................................................
	ret_list_items[15] = Tcl_NewStringObj("0", 1);

	ret_list_items[16] = Tcl_NewStringObj("mtime", 5);
	ret_list_items[17] = Tcl_NewStringObj("0", 1);

	ret_list_items[18] = Tcl_NewStringObj("ctime", 5);
	ret_list_items[19] = Tcl_NewStringObj("0", 1);

	for (idx = 0; idx < (sizeof(ret_list_items) / sizeof(ret_list_items[0])); idx++) {
		Tcl_IncrRefCount(ret_list_items[idx]);
	}

	ret_list = Tcl_NewListObj(sizeof(ret_list_items) / sizeof(ret_list_items[0]), ret_list_items);

	Tcl_IncrRefCount(ret_list);

	for (idx = 0; idx < (sizeof(ret_list_items) / sizeof(ret_list_items[0])); idx++) {
		Tcl_DecrRefCount(ret_list_items[idx]);
	}

	Tcl_SetObjResult(interp, ret_list);

	Tcl_DecrRefCount(ret_list);

	return(TCL_OK);
}

static int getData(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
	struct cvfs_data *finfo = NULL;
	cmd_getData_t *cmd_getData;
................................................................................
	if (end < start) {
		Tcl_SetResult(interp, "Invalid arguments, start must be less than end", TCL_STATIC);

		return(TCL_ERROR);
	}

	ret_str = Tcl_NewByteArrayObj(finfo->data + start, (end - start));

	Tcl_IncrRefCount(ret_str);

	Tcl_SetObjResult(interp, ret_str);

	Tcl_DecrRefCount(ret_str);

	return(TCL_OK);
}

static int getChildren(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
	struct cvfs_data *finfo = NULL;
	cmd_getChildren_t *cmd_getChildren;
................................................................................

	ret_list = Tcl_NewObj();
	if (ret_list == NULL) {
		Tcl_SetResult(interp, "Failed to allocate new object", TCL_STATIC);

		return(TCL_ERROR);
	}

	Tcl_IncrRefCount(ret_list);

	children = malloc(sizeof(*children) * num_children);

	num_children = cmd_getChildren(file, children, num_children);

	for (idx = 0; idx < num_children; idx++) {
		finfo = cmd_getData(NULL, children[idx]);
................................................................................
		if (finfo == NULL || finfo->name == NULL) {
			continue;
		}

		child = finfo->name;

		ret_curr_obj = Tcl_NewStringObj(child, strlen(child));

		Tcl_IncrRefCount(ret_curr_obj);

		Tcl_ListObjAppendList(interp, ret_list, ret_curr_obj);

		Tcl_DecrRefCount(ret_curr_obj);
	}

	free(children);

	Tcl_SetObjResult(interp, ret_list);

	Tcl_DecrRefCount(ret_list);

	return(TCL_OK);
}