summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-06-26 08:10:36 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-06-26 08:10:36 (GMT)
commite0e8990257bc75fdafa895f309145353c400923e (patch)
tree99514082758c1587a38dc927f496426c5dfb5dde
parentb7baefb37be1711dc8aefbbed9e9670b0926e1be (diff)
downloadtcl-ticket_9b2e636361.zip
tcl-ticket_9b2e636361.tar.gz
tcl-ticket_9b2e636361.tar.bz2
Allocate encoding name, so caller of Tcl_RegisterConfig() doesn't need to keep it forever. ticket_9b2e636361
Fix some comments.
-rw-r--r--generic/tclConfig.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/generic/tclConfig.c b/generic/tclConfig.c
index ffed6f2..702ab82 100644
--- a/generic/tclConfig.c
+++ b/generic/tclConfig.c
@@ -34,7 +34,7 @@
typedef struct QCCD {
Tcl_Obj *pkg;
Tcl_Interp *interp;
- CONST char *encoding;
+ char *encoding;
} QCCD;
/*
@@ -82,15 +82,20 @@ Tcl_RegisterConfig(
QCCD *cdPtr = (QCCD *)ckalloc(sizeof(QCCD));
cdPtr->interp = interp;
- cdPtr->encoding = valEncoding;
+ if (valEncoding) {
+ cdPtr->encoding = ckalloc(strlen(valEncoding)+1);
+ strcpy(cdPtr->encoding, valEncoding);
+ } else {
+ cdPtr->encoding = NULL;
+ }
cdPtr->pkg = Tcl_NewStringObj(pkgName, -1);
/*
* Phase I: Adding the provided information to the internal database of
- * package meta data. Only if we have an ok encoding.
+ * package meta data.
*
* Phase II: Create a command for querying this database, specific to the
- * package registerting its configuration. This is the approved interface
+ * package registering its configuration. This is the approved interface
* in TIP 59. In the future a more general interface should be done, as
* followup to TIP 59. Simply because our database is now general across
* packages, and not a structure tied to one package.
@@ -313,6 +318,9 @@ QueryConfigDelete(
Tcl_Obj *pDB = GetConfigDict(cdPtr->interp);
Tcl_DictObjRemove(NULL, pDB, pkgName);
Tcl_DecrRefCount(pkgName);
+ if (cdPtr->encoding) {
+ ckfree((char *)cdPtr->encoding);
+ }
ckfree((char *)cdPtr);
}