diff options
author | KUDr <kudr@openttd.org> | 2007-01-11 17:29:39 +0000 |
---|---|---|
committer | KUDr <kudr@openttd.org> | 2007-01-11 17:29:39 +0000 |
commit | 33be1ecfb1a9056b027d50d7b558cff87c5b744d (patch) | |
tree | d644a3831ca0947198b191fa3e4e8973d3a9786e /src/newgrf_config.cpp | |
parent | 91ff74641060445dc1647bbf05baeb03b45c3099 (diff) | |
download | openttd-33be1ecfb1a9056b027d50d7b558cff87c5b744d.tar.xz |
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
Diffstat (limited to 'src/newgrf_config.cpp')
-rw-r--r-- | src/newgrf_config.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index c624328dd..1c49bd207 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -119,12 +119,10 @@ void ClearGRFConfigList(GRFConfig **config) * @return pointer to the last value added to the destination list */ GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src) { - GRFConfig *c; - /* Clear destination as it will be overwritten */ ClearGRFConfigList(dst); for (; src != NULL; src = src->next) { - CallocT(&c, 1); + GRFConfig *c = CallocT<GRFConfig>(1); *c = *src; if (src->filename != NULL) c->filename = strdup(src->filename); if (src->name != NULL) c->name = strdup(src->name); @@ -245,7 +243,6 @@ static uint ScanPath(const char *path) struct stat sb; struct dirent *dirent; DIR *dir; - GRFConfig *c; if ((dir = opendir(path)) == NULL) return 0; @@ -270,7 +267,7 @@ static uint ScanPath(const char *path) if (ext == NULL) continue; if (strcasecmp(ext, ".grf") != 0) continue; - CallocT(&c, 1); + GRFConfig *c = CallocT<GRFConfig>(1); c->filename = strdup(file); if (FillGRFDetails(c, false)) { @@ -375,7 +372,7 @@ char *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create) if (!create) return NULL; - CallocT(&grf, 1); + grf = CallocT<UnknownGRF>(1); grf->grfid = grfid; grf->next = unknown_grfs; ttd_strlcpy(grf->name, UNKNOWN_GRF_NAME_PLACEHOLDER, sizeof(grf->name)); @@ -446,8 +443,7 @@ static void Load_NGRF(void) GRFConfig **last = &first; while (SlIterateArray() != -1) { - GRFConfig *c; - CallocT(&c, 1); + GRFConfig *c = CallocT<GRFConfig>(1); SlObject(c, _grfconfig_desc); /* Append our configuration to the list */ |