Skip to content

Instantly share code, notes, and snippets.

@nikic
Last active October 18, 2015 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikic/960e130c9d4d0737b5f9 to your computer and use it in GitHub Desktop.
Save nikic/960e130c9d4d0737b5f9 to your computer and use it in GitHub Desktop.
diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c
index 308437e..ebc4d1e 100644
--- a/ext/date/lib/parse_tz.c
+++ b/ext/date/lib/parse_tz.c
@@ -438,7 +438,7 @@ static struct location_info **create_location_table(void)
return NULL;
}
- li = timelib_calloc(LOCINFO_HASH_SIZE, sizeof *li);
+ li = calloc(LOCINFO_HASH_SIZE, sizeof *li);
while (fgets(line, sizeof line, fp)) {
char *p = line, *code, *name, *comment;
@@ -489,14 +489,14 @@ static struct location_info **create_location_table(void)
*p = '\0';
hash = tz_hash(name);
- i = timelib_malloc(sizeof *i);
+ i = malloc(sizeof *i);
memcpy(i->code, code, 2);
strncpy(i->name, name, sizeof i->name);
- i->comment = timelib_strdup(comment);
+ i->comment = strdup(comment);
i->longitude = longitude;
i->latitude = latitude;
i->next = li[hash];
@@ -556,13 +556,13 @@ static void create_zone_index(timelib_tzdb *db)
/* LIFO stack to hold directory entries to scan; each slot is a
* directory name relative to the zoneinfo prefix. */
dirstack_size = 32;
- dirstack = timelib_malloc(dirstack_size * sizeof *dirstack);
+ dirstack = malloc(dirstack_size * sizeof *dirstack);
dirstack_top = 1;
- dirstack[0] = timelib_strdup("");
+ dirstack[0] = strdup("");
/* Index array. */
index_size = 64;
- db_index = timelib_malloc(index_size * sizeof *db_index);
+ db_index = malloc(index_size * sizeof *db_index);
index_next = 0;
do {
@@ -595,19 +595,19 @@ static void create_zone_index(timelib_tzdb *db)
if (S_ISDIR(st.st_mode)) {
if (dirstack_top == dirstack_size) {
dirstack_size *= 2;
- dirstack = timelib_realloc(dirstack,
+ dirstack = realloc(dirstack,
dirstack_size * sizeof *dirstack);
}
- dirstack[dirstack_top++] = timelib_strdup(name);
+ dirstack[dirstack_top++] = strdup(name);
}
else {
if (index_next == index_size) {
index_size *= 2;
- db_index = timelib_realloc(db_index,
+ db_index = realloc(db_index,
index_size * sizeof *db_index);
}
- db_index[index_next++].id = timelib_strdup(name);
+ db_index[index_next++].id = strdup(name);
}
}
@@ -615,7 +615,7 @@ static void create_zone_index(timelib_tzdb *db)
}
if (count != -1) free(ents);
- timelib_free(top);
+ free(top);
} while (dirstack_top);
qsort(db_index, index_next, sizeof *db_index, sysdbcmp);
@@ -623,7 +623,7 @@ static void create_zone_index(timelib_tzdb *db)
db->index = db_index;
db->index_size = index_next;
- timelib_free(dirstack);
+ free(dirstack);
}
#define FAKE_HEADER "1234\0??\1??"
@@ -636,7 +636,7 @@ static void fake_data_segment(timelib_tzdb *sysdb,
size_t n;
char *data, *p;
- data = timelib_malloc(3 * sysdb->index_size + 7);
+ data = malloc(3 * sysdb->index_size + 7);
p = mempcpy(data, FAKE_HEADER, sizeof(FAKE_HEADER) - 1);
@@ -798,7 +798,7 @@ const timelib_tzdb *timelib_builtin_db(void)
{
#ifdef HAVE_SYSTEM_TZDATA
if (timezonedb_system == NULL) {
- timelib_tzdb *tmp = timelib_malloc(sizeof *tmp);
+ timelib_tzdb *tmp = malloc(sizeof *tmp);
tmp->version = "0.system";
tmp->data = NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment