diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c index 5c59913646b..9d4ea177ddb 100644 --- a/src/backend/storage/file/buffile.c +++ b/src/backend/storage/file/buffile.c @@ -172,8 +172,7 @@ extendBufFile(BufFile *file) CurrentResourceOwner = oldowner; - file->files = (File *) repalloc(file->files, - (file->numFiles + 1) * sizeof(File)); + file->files = repalloc_array(file->files, File, file->numFiles + 1); file->files[file->numFiles] = pfile; file->numFiles++; } @@ -915,8 +914,7 @@ BufFileAppend(BufFile *target, BufFile *source) if (target->resowner != source->resowner) elog(ERROR, "could not append BufFile with non-matching resource owner"); - target->files = (File *) - repalloc(target->files, sizeof(File) * newNumFiles); + target->files = repalloc_array(target->files, File, newNumFiles); for (i = target->numFiles; i < newNumFiles; i++) target->files[i] = source->files[i - target->numFiles]; target->numFiles = newNumFiles; diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 9969bb81716..190c9974494 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -976,7 +976,7 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open) #endif size = 1024; - fd = (int *) palloc(size * sizeof(int)); + fd = palloc_array(int, size); #ifdef HAVE_GETRLIMIT getrlimit_status = getrlimit(RLIMIT_NOFILE, &rlim); @@ -1011,7 +1011,7 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open) if (used >= size) { size *= 2; - fd = (int *) repalloc(fd, size * sizeof(int)); + fd = repalloc_array(fd, int, size); } fd[used++] = thisfd;