Commit a9760303 authored by vysheng's avatar vysheng

realloc->trealloc

parent ccc76dd9
......@@ -685,7 +685,7 @@ void replay_log_event (void) {
assert (C->user_list[i].user_id != user);
}
C->user_list_size ++;
C->user_list = realloc (C->user_list, 12 * C->user_list_size);
C->user_list = trealloc (C->user_list, 12 * C->user_list_size);
C->user_list[C->user_list_size - 1].user_id = user;
C->user_list[C->user_list_size - 1].inviter_id = inviter;
C->user_list[C->user_list_size - 1].date = date;
......@@ -715,7 +715,7 @@ void replay_log_event (void) {
}
assert (C->user_list[C->user_list_size - 1].user_id == user);
C->user_list_size --;
C->user_list = realloc (C->user_list, 12 * C->user_list_size);
C->user_list = trealloc (C->user_list, 12 * C->user_list_size);
C->user_list_version = version;
}
break;
......
......@@ -31,6 +31,12 @@ static void out_of_memory (void) {
assert (0 && "Out of memory");
}
void *trealloc (void *ptr, size_t size) {
void *p = realloc (ptr, size);
ensure_ptr (p);
return p;
}
void *talloc (size_t size) {
void *p = malloc (size);
ensure_ptr (p);
......
......@@ -21,6 +21,7 @@
#define __TOOLS_H__
void *talloc (size_t size);
void *trealloc (void *ptr, size_t size);
void *talloc0 (size_t size);
char *tstrdup (const char *s);
void ensure (int r);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment