mailing list of musl libc
 help / color / mirror / code / Atom feed
a7827604453e69bd2720727627ae57144003121b blob 506 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
#define _BSD_SOURCE
#include <errno.h>
#include <stdlib.h>
#include <string.h>

void *recallocarray(void *ptr, size_t om, size_t m, size_t n)
{
	void *newptr;
	size_t old_size = om * n, new_size;

	if (n && m > -1 / n) {
		errno = ENOMEM;
		return 0;
	}
	new_size = m * n;

	if (new_size <= old_size) {
		memset((char *) ptr + new_size, 0, old_size - new_size);
	}

	newptr = realloc(ptr, m * n);
	if (new_size > old_size) {
		memset((char *) ptr + old_size, 0, new_size - old_size);
	}

	return newptr;
}
debug log:

solving a7827604 ...
found a7827604 in https://inbox.vuxu.org/musl/20200801214216.10452-1-ariadne@dereferenced.org/

applying [1/1] https://inbox.vuxu.org/musl/20200801214216.10452-1-ariadne@dereferenced.org/
diff --git a/src/malloc/recallocarray.c b/src/malloc/recallocarray.c
new file mode 100644
index 00000000..a7827604

Checking patch src/malloc/recallocarray.c...
Applied patch src/malloc/recallocarray.c cleanly.

index at:
100644 a7827604453e69bd2720727627ae57144003121b	src/malloc/recallocarray.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).