summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authornineonine <mail4chemik@gmail.com>2021-10-25 09:38:22 -0700
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-12-10 06:16:41 -0500
commitf573cb16debc5424e502b3777430c02ae6d0b475 (patch)
treedeb8abbab6a0ff0ab1df96a76a014d3d3017ccd1 /rts
parent80a25502c1f9ac4597c9408931df1bf03cad5b9e (diff)
downloadhaskell-f573cb16debc5424e502b3777430c02ae6d0b475.tar.gz
rts: use allocation helpers from RtsUtils
Just a tiny cleanup inspired by the following comment: https://gitlab.haskell.org/ghc/ghc/-/issues/19437#note_334271 I was just getting familiar with rts code base so I thought might as well do this.
Diffstat (limited to 'rts')
-rw-r--r--rts/CheckUnload.c6
-rw-r--r--rts/Hpc.c2
-rw-r--r--rts/Libdw.c6
-rw-r--r--rts/Pool.c6
-rw-r--r--rts/RtsAPI.c4
-rw-r--r--rts/RtsFlags.c2
-rw-r--r--rts/linker/PEi386.c2
-rw-r--r--rts/linker/macho/plt.c2
-rw-r--r--rts/win32/WorkQueue.c4
9 files changed, 17 insertions, 17 deletions
diff --git a/rts/CheckUnload.c b/rts/CheckUnload.c
index f210d629b1..3761fd2bf5 100644
--- a/rts/CheckUnload.c
+++ b/rts/CheckUnload.c
@@ -182,8 +182,8 @@ static OCSectionIndices *createOCSectionIndices(void)
static void freeOCSectionIndices(OCSectionIndices *s_indices)
{
- free(s_indices->indices);
- free(s_indices);
+ stgFree(s_indices->indices);
+ stgFree(s_indices);
}
void initUnloadCheck()
@@ -231,7 +231,7 @@ static void reserveOCSectionIndices(OCSectionIndices *s_indices, int len)
s_indices->capacity = new_capacity;
s_indices->indices = new_indices;
- free(old_indices);
+ stgFree(old_indices);
}
// Insert object section indices of a single ObjectCode. Invalidates 'sorted'
diff --git a/rts/Hpc.c b/rts/Hpc.c
index 7a9e42caed..edbad500c0 100644
--- a/rts/Hpc.c
+++ b/rts/Hpc.c
@@ -137,7 +137,7 @@ readTix(void) {
tmpModule -> hashNo = (unsigned int)expectWord64();
ws();
tmpModule -> tickCount = (int)expectWord64();
- tmpModule -> tixArr = (StgWord64 *)calloc(tmpModule->tickCount,sizeof(StgWord64));
+ tmpModule -> tixArr = (StgWord64 *)stgCallocBytes(tmpModule->tickCount,sizeof(StgWord64), "readTix");
ws();
expect('[');
ws();
diff --git a/rts/Libdw.c b/rts/Libdw.c
index 25399a00fe..335d99861b 100644
--- a/rts/Libdw.c
+++ b/rts/Libdw.c
@@ -95,7 +95,7 @@ LibdwSession *libdwInit() {
session->dwfl = dwfl_begin (&proc_callbacks);
if (session->dwfl == NULL) {
sysErrorBelch("dwfl_begin failed: %s", dwfl_errmsg(dwfl_errno()));
- free(session);
+ stgFree(session);
return NULL;
}
@@ -122,7 +122,7 @@ LibdwSession *libdwInit() {
fail:
dwfl_end(session->dwfl);
- free(session);
+ stgFree(session);
return NULL;
}
@@ -194,7 +194,7 @@ int libdwForEachFrameOutwards(Backtrace *bt,
if (res != 0) break;
}
}
- free(chunks);
+ stgFree(chunks);
return res;
}
diff --git a/rts/Pool.c b/rts/Pool.c
index 7fb32acc62..91af4ba49b 100644
--- a/rts/Pool.c
+++ b/rts/Pool.c
@@ -69,7 +69,7 @@ int poolFree(Pool *pool) {
closeCondition(&pool->cond);
closeMutex(&pool->mutex);
#endif
- free(pool);
+ stgFree(pool);
return 0;
}
@@ -79,7 +79,7 @@ static void free_available(Pool *pool, uint32_t size) {
PoolEntry *ent = pool->available;
pool->free_fn(ent->thing);
pool->available = ent->next;
- free(ent);
+ stgFree(ent);
pool->current_size--;
}
}
@@ -167,7 +167,7 @@ void poolRelease(Pool *pool, void *thing) {
if (pool->current_size > pool->desired_size
|| ent->flags & FLAG_SHOULD_FREE) {
pool->free_fn(ent->thing);
- free(ent);
+ stgFree(ent);
} else {
ent->next = pool->available;
pool->available = ent;
diff --git a/rts/RtsAPI.c b/rts/RtsAPI.c
index 469f4c52f6..145f36bc55 100644
--- a/rts/RtsAPI.c
+++ b/rts/RtsAPI.c
@@ -752,7 +752,7 @@ PauseToken *rts_pause (void)
// Now we own all capabilities so we own rts_pausing_task and may set it.
rts_pausing_task = task;
- PauseToken *token = malloc(sizeof(PauseToken));
+ PauseToken *token = stgMallocBytes(sizeof(PauseToken), "rts_pause");
token->capability = task->cap;
return token;
}
@@ -774,7 +774,7 @@ void rts_resume (PauseToken *pauseToken)
// capabilities.
releaseAllCapabilities(n_capabilities, NULL, task);
exitMyTask();
- free(pauseToken);
+ stgFree(pauseToken);
}
// See RtsAPI.h
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index 50de729183..11399e3103 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -2252,7 +2252,7 @@ static bool read_heap_profiling_flag(const char *arg)
RtsFlags.ProfFlags.bioSelector = selector;
break;
default:
- free(selector);
+ stgFree(selector);
}
}
break;
diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
index 9f955e1cf8..f186da0af8 100644
--- a/rts/linker/PEi386.c
+++ b/rts/linker/PEi386.c
@@ -851,7 +851,7 @@ bool removeLibrarySearchPath_PEi386(HsPtr dll_path_index)
{
warnMissingKBLibraryPaths();
result = SetEnvironmentVariableW(L"PATH", (LPCWSTR)dll_path_index);
- free(dll_path_index);
+ stgFree(dll_path_index);
}
if (!result) {
diff --git a/rts/linker/macho/plt.c b/rts/linker/macho/plt.c
index 33563f62d5..ed005ba447 100644
--- a/rts/linker/macho/plt.c
+++ b/rts/linker/macho/plt.c
@@ -84,7 +84,7 @@ freeStubs(Section * section) {
while(last->next != NULL) {
Stub * t = last;
last = last->next;
- free(t);
+ stgFree(t);
}
section->info->stubs = NULL;
section->info->nstubs = 0;
diff --git a/rts/win32/WorkQueue.c b/rts/win32/WorkQueue.c
index 1f4fb6a467..1d2e9c7a41 100644
--- a/rts/win32/WorkQueue.c
+++ b/rts/win32/WorkQueue.c
@@ -68,7 +68,7 @@ FreeWorkQueue ( WorkQueue* pq )
/* Free any remaining work items. */
for (i = 0; i < WORKQUEUE_SIZE; i++) {
if (pq->items[i] != NULL) {
- free(pq->items[i]);
+ stgFree(pq->items[i]);
}
}
@@ -82,7 +82,7 @@ FreeWorkQueue ( WorkQueue* pq )
CloseHandle(pq->roomAvailable);
}
OS_CLOSE_LOCK(&pq->queueLock);
- free(pq);
+ stgFree(pq);
return;
}