Commit e86ed5e3 authored by Gerd Stolpmann's avatar Gerd Stolpmann

Merge branch 'master' into 'master'

Fix: a memory leak in platform_c.c

Caught this as part of a large-scale audit of C stubs related to [this PR](https://github.com/ocaml/ocaml/pull/71).

Haven't tested the fix. Please, take a careful look at it.

It is also advised to upgrade the bundled `postgresql` library to the latest version, which makes use of the undocumented `caml_stat_*` functions in a consistent way.

See merge request !1
parents fa1d3341 9d8ab28f
Pipeline #93342393 skipped
......@@ -2,7 +2,7 @@
/* Helpers for mapred performance */
#define _GNU_SOURCE
#define _GNU_SOURCE
#include <string.h>
#include <pthread.h>
......@@ -16,7 +16,7 @@
#define Nothing ((value) 0)
/* external find_lf : Netsys_mem.memory -> int -> int -> int
/* external find_lf : Netsys_mem.memory -> int -> int -> int
= "mapred_find_lf"
Looks for LF char from mem[pos] to mem[endpos-1] and returns the
......@@ -42,11 +42,11 @@ CAMLprim value mapred_str_cmp(value s1, value p1, value l1,
{
int d;
size_t n1, n2, n;
n1 = Long_val(l1);
n2 = Long_val(l2);
n = (n1 < n2) ? n1 : n2;
d = memcmp(String_val(s1) + Long_val(p1),
String_val(s2) + Long_val(p2),
n);
......@@ -82,7 +82,7 @@ CAMLprim value mapred_rev_find_lf (value memv, value posv, value endposv) {
char *m = (char *) mem->data;
char *found;
#ifdef HAVE_MEMRCHR
#ifdef HAVE_MEMRCHR
found = (char *) memrchr(m + pos, '\n', endpos-pos);
#else
found = NULL;
......@@ -124,7 +124,7 @@ static void body_split_pass(struct split_engine *se)
char **ringbuf;
int ringbuf_head;
int ringbuf_len;
cursor = se->cursor;
end = se->end;
ringbuf = se->ringbuf;
......@@ -160,7 +160,7 @@ static void *body_split_engine(void *arg)
pthread_mutex_lock(&(se->m));
while (se->enabled && se->cursor < se->end) {
/* fprintf(stderr, "Loop 1\n"); */
while (se->enabled &&
while (se->enabled &&
se->cursor < se->end &&
se->ringbuf_len >= N_MAX_MIN
) {
......@@ -188,7 +188,7 @@ static void init_split_engine(struct split_engine *se,
{
pthread_t thr;
int code;
se->enabled = 1;
se->running = 1;
se->cursor = (char *) Data_bigarray_val(ba);
......@@ -223,7 +223,7 @@ static struct custom_operations splitter_ops = {
#define Engine_val(v) ((struct split_engine **) (Data_custom_val(v)))
CAMLprim value mapred_splitter_create(value ba)
CAMLprim value mapred_splitter_create(value ba)
{
struct split_engine *se;
value r;
......@@ -256,6 +256,7 @@ CAMLprim value mapred_splitter_stop(value eng)
pthread_cond_destroy(&(se->c));
pthread_mutex_destroy(&(se->m));
stat_free(se->ringbuf);
stat_free(se);
*(Engine_val(eng)) = NULL;
};
return Val_unit;
......
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