Debian Codegraph @

templates/man3/malloc.3.pot

raw
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2026-06-05 06:30+0200\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <[email protected]>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
21 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
22 #, no-wrap
23 msgid "malloc"
24 msgstr ""
25
26 #. type: TH
27 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
28 #: opensuse-tumbleweed
29 #, no-wrap
30 msgid "2026-02-08"
31 msgstr ""
32
33 #. type: TH
34 #: archlinux debian-unstable
35 #, no-wrap
36 msgid "Linux man-pages 6.18"
37 msgstr ""
38
39 #. type: SH
40 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
41 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
42 #, no-wrap
43 msgid "NAME"
44 msgstr ""
45
46 #. type: Plain text
47 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
48 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
49 msgid ""
50 "malloc, free, calloc, realloc, reallocarray - allocate and free dynamic "
51 "memory"
52 msgstr ""
53
54 #. type: SH
55 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
56 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
57 #, no-wrap
58 msgid "LIBRARY"
59 msgstr ""
60
61 #. type: Plain text
62 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
63 #: opensuse-leap-16-1 opensuse-tumbleweed
64 msgid "Standard C library (I<libc>,\\ I<-lc>)"
65 msgstr ""
66
67 #. type: SH
68 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
69 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
70 #, no-wrap
71 msgid "SYNOPSIS"
72 msgstr ""
73
74 #. type: Plain text
75 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
76 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
77 #, no-wrap
78 msgid "B<#include E<lt>stdlib.hE<gt>>\n"
79 msgstr ""
80
81 #. type: Plain text
82 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
83 #: opensuse-tumbleweed
84 #, no-wrap
85 msgid ""
86 "B<void *malloc(size_t >I<size>B<);>\n"
87 "B<void free(void *_Nullable >I<p>B<);>\n"
88 "B<void *calloc(size_t >I<n>B<, size_t >I<size>B<);>\n"
89 "B<void *realloc(void *_Nullable >I<p>B<, size_t >I<size>B<);>\n"
90 "B<void *reallocarray(void *_Nullable >I<p>B<, size_t >I<n>B<, size_t >I<size>B<);>\n"
91 msgstr ""
92
93 #. type: Plain text
94 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
95 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
96 msgid ""
97 "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
98 msgstr ""
99
100 #. type: Plain text
101 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
102 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
103 msgid "B<reallocarray>():"
104 msgstr ""
105
106 #. type: Plain text
107 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
108 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
109 #, no-wrap
110 msgid ""
111 " Since glibc 2.29:\n"
112 " _DEFAULT_SOURCE\n"
113 " glibc 2.28 and earlier:\n"
114 " _GNU_SOURCE\n"
115 msgstr ""
116
117 #. type: SH
118 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
119 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
120 #, no-wrap
121 msgid "DESCRIPTION"
122 msgstr ""
123
124 #. type: SS
125 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
126 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
127 #, no-wrap
128 msgid "malloc()"
129 msgstr ""
130
131 #. type: Plain text
132 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
133 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
134 msgid ""
135 "The B<malloc>() function allocates I<size> bytes and returns a pointer to "
136 "the allocated memory. I<The memory is not initialized>. If I<size> is 0, "
137 "then B<malloc>() returns a unique pointer value that can later be "
138 "successfully passed to B<free>(). (See \"Nonportable behavior\" for "
139 "portability issues.)"
140 msgstr ""
141
142 #. type: SS
143 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
144 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
145 #, no-wrap
146 msgid "free()"
147 msgstr ""
148
149 #. type: Plain text
150 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
151 #: opensuse-tumbleweed
152 msgid ""
153 "The B<free>() function frees the memory space pointed to by I<p>, which "
154 "must have been returned by a previous call to B<malloc>() or related "
155 "functions. Otherwise, or if I<p> has already been freed, undefined behavior "
156 "occurs. If I<p> is NULL, no operation is performed."
157 msgstr ""
158
159 #. type: SS
160 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
161 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
162 #, no-wrap
163 msgid "calloc()"
164 msgstr ""
165
166 #. type: Plain text
167 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
168 #: opensuse-leap-16-1 opensuse-tumbleweed
169 msgid ""
170 "The B<calloc>() function allocates memory for an array of I<n> elements of "
171 "I<size> bytes each and returns a pointer to the allocated memory. The "
172 "memory is set to zero. If I<n> or I<size> is 0, then B<calloc>() returns a "
173 "unique pointer value that can later be successfully passed to B<free>()."
174 msgstr ""
175
176 #. type: Plain text
177 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
178 #: opensuse-leap-16-1 opensuse-tumbleweed
179 msgid ""
180 "If the multiplication of I<n> and I<size> would result in integer overflow, "
181 "then B<calloc>() returns an error. By contrast, an integer overflow would "
182 "not be detected in the following call to B<malloc>(), with the result that "
183 "an incorrectly sized block of memory would be allocated:"
184 msgstr ""
185
186 #. type: Plain text
187 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
188 #: opensuse-leap-16-1 opensuse-tumbleweed
189 #, no-wrap
190 msgid "malloc(n * size);\n"
191 msgstr ""
192
193 #. type: SS
194 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
195 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
196 #, no-wrap
197 msgid "realloc()"
198 msgstr ""
199
200 #. type: Plain text
201 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
202 #: opensuse-tumbleweed
203 msgid ""
204 "The B<realloc>() function changes the size of the memory block pointed to "
205 "by I<p> to I<size> bytes. The contents of the memory will be unchanged in "
206 "the range from the start of the region up to the minimum of the old and new "
207 "sizes. If the new size is larger than the old size, the added memory will "
208 "I<not> be initialized."
209 msgstr ""
210
211 #. type: Plain text
212 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
213 #: opensuse-tumbleweed
214 msgid ""
215 "If I<p> is NULL, then the call is equivalent to I<malloc(size)>, for all "
216 "values of I<size>."
217 msgstr ""
218
219 #. type: Plain text
220 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
221 #: opensuse-tumbleweed
222 msgid ""
223 "If I<size> is equal to zero, and I<p> is not NULL, then the call is "
224 "equivalent to I<free(p)> (but see \"Nonportable behavior\" for portability "
225 "issues)."
226 msgstr ""
227
228 #. type: Plain text
229 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
230 #: opensuse-tumbleweed
231 msgid ""
232 "Unless I<p> is NULL, it must have been returned by an earlier call to "
233 "B<malloc> or related functions. If the area pointed to was moved, a "
234 "I<free(p)> is done."
235 msgstr ""
236
237 #. type: SS
238 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
239 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
240 #, no-wrap
241 msgid "reallocarray()"
242 msgstr ""
243
244 #. type: Plain text
245 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
246 #: opensuse-tumbleweed
247 msgid ""
248 "The B<reallocarray>() function changes the size of (and possibly moves) "
249 "the memory block pointed to by I<p> to be large enough for an array of I<n> "
250 "elements, each of which is I<size> bytes. It is equivalent to the call"
251 msgstr ""
252
253 #. type: Plain text
254 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
255 #: opensuse-tumbleweed
256 #, no-wrap
257 msgid "realloc(p, n * size);\n"
258 msgstr ""
259
260 #. type: Plain text
261 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
262 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
263 msgid ""
264 "However, unlike that B<realloc>() call, B<reallocarray>() fails safely in "
265 "the case where the multiplication would overflow. If such an overflow "
266 "occurs, B<reallocarray>() returns an error."
267 msgstr ""
268
269 #. type: SH
270 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
271 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
272 #, no-wrap
273 msgid "RETURN VALUE"
274 msgstr ""
275
276 #. type: Plain text
277 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
278 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
279 msgid ""
280 "The B<malloc>(), B<calloc>(), B<realloc>(), and B<reallocarray>() functions "
281 "return a pointer to the allocated memory, which is suitably aligned for any "
282 "type that fits into the requested size or less. On error, these functions "
283 "return NULL and set I<errno>. Attempting to allocate more than "
284 "B<PTRDIFF_MAX> bytes is considered an error, as an object that large could "
285 "cause later pointer subtraction to overflow."
286 msgstr ""
287
288 #. type: Plain text
289 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
290 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
291 msgid "The B<free>() function returns no value, and preserves I<errno>."
292 msgstr ""
293
294 #. type: Plain text
295 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
296 #: opensuse-tumbleweed
297 msgid ""
298 "The B<realloc>() and B<reallocarray>() functions return NULL if I<p> is "
299 "not NULL and the requested size is zero; this is not considered an error. "
300 "(See \"Nonportable behavior\" for portability issues.) Otherwise, the "
301 "returned pointer may be the same as I<p> if the allocation was not moved "
302 "(e.g., there was room to expand the allocation in-place), or different from "
303 "I<p> if the allocation was moved to a new address. If these functions fail, "
304 "the original block is left untouched; it is not freed or moved."
305 msgstr ""
306
307 #. type: SH
308 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
309 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
310 #, no-wrap
311 msgid "ERRORS"
312 msgstr ""
313
314 #. type: Plain text
315 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
316 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
317 msgid ""
318 "B<calloc>(), B<malloc>(), B<realloc>(), and B<reallocarray>() can fail with "
319 "the following error:"
320 msgstr ""
321
322 #. type: TP
323 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
324 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
325 #, no-wrap
326 msgid "B<ENOMEM>"
327 msgstr ""
328
329 #. type: Plain text
330 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
331 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
332 msgid ""
333 "Out of memory. Possibly, the application hit the B<RLIMIT_AS> or "
334 "B<RLIMIT_DATA> limit described in B<getrlimit>(2). Another reason could be "
335 "that the number of mappings created by the caller process exceeded the limit "
336 "specified by I</proc/sys/vm/max_map_count>."
337 msgstr ""
338
339 #. type: SH
340 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
341 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
342 #, no-wrap
343 msgid "ATTRIBUTES"
344 msgstr ""
345
346 #. type: Plain text
347 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
348 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
349 msgid ""
350 "For an explanation of the terms used in this section, see B<attributes>(7)."
351 msgstr ""
352
353 #. type: tbl table
354 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
355 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
356 #, no-wrap
357 msgid "Interface"
358 msgstr ""
359
360 #. type: tbl table
361 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
362 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
363 #, no-wrap
364 msgid "Attribute"
365 msgstr ""
366
367 #. type: tbl table
368 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
369 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
370 #, no-wrap
371 msgid "Value"
372 msgstr ""
373
374 #. type: tbl table
375 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
376 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
377 #, no-wrap
378 msgid ".na\n"
379 msgstr ""
380
381 #. type: tbl table
382 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
383 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
384 #, no-wrap
385 msgid ".nh\n"
386 msgstr ""
387
388 #. type: tbl table
389 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
390 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
391 #, no-wrap
392 msgid ""
393 "B<malloc>(),\n"
394 "B<free>(),\n"
395 "B<calloc>(),\n"
396 "B<realloc>()"
397 msgstr ""
398
399 #. type: tbl table
400 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
401 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
402 #, no-wrap
403 msgid "Thread safety"
404 msgstr ""
405
406 #. type: tbl table
407 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
408 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
409 #, no-wrap
410 msgid "MT-Safe"
411 msgstr ""
412
413 #. type: SH
414 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
415 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
416 #, no-wrap
417 msgid "STANDARDS"
418 msgstr ""
419
420 #. type: TP
421 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
422 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
423 #, no-wrap
424 msgid "B<malloc>()"
425 msgstr ""
426
427 #. type: TQ
428 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
429 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
430 #, no-wrap
431 msgid "B<free>()"
432 msgstr ""
433
434 #. type: TQ
435 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
436 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
437 #, no-wrap
438 msgid "B<calloc>()"
439 msgstr ""
440
441 #. type: TQ
442 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
443 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
444 #, no-wrap
445 msgid "B<realloc>()"
446 msgstr ""
447
448 #. type: Plain text
449 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
450 #: opensuse-tumbleweed
451 msgid "C23, POSIX.1-2024."
452 msgstr ""
453
454 #. type: TP
455 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
456 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
457 #, no-wrap
458 msgid "B<reallocarray>()"
459 msgstr ""
460
461 #. type: Plain text
462 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
463 #: opensuse-tumbleweed
464 msgid "POSIX.1-2024."
465 msgstr ""
466
467 #. type: SS
468 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
469 #: opensuse-tumbleweed
470 #, no-wrap
471 msgid "realloc(p, 0)"
472 msgstr ""
473
474 #. type: Plain text
475 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
476 #: opensuse-tumbleweed
477 msgid ""
478 "The behavior of I<realloc(p,\\ 0)> in glibc doesn't conform to any of C99, "
479 "C11, POSIX.1-2001, POSIX.1-2004, POSIX.1-2008, POSIX.1-2013, POSIX.1-2017, "
480 "or POSIX.1-2024. The C17 specification was changed to make it conforming, "
481 "but that specification made it impossible to write code that reliably "
482 "determines if the input pointer is freed after I<realloc(p,\\ 0)>, and C23 "
483 "changed it again to make this undefined behavior, acknowledging that the C17 "
484 "specification was broad enough, so that undefined behavior wasn't worse than "
485 "that."
486 msgstr ""
487
488 #. type: Plain text
489 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
490 #: opensuse-tumbleweed
491 msgid "B<reallocarray>() suffers the same issues in glibc."
492 msgstr ""
493
494 #. type: Plain text
495 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
496 #: opensuse-tumbleweed
497 msgid "musl libc and the BSDs conform to all versions of ISO C and POSIX.1."
498 msgstr ""
499
500 #. type: Plain text
501 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
502 #: opensuse-tumbleweed
503 msgid ""
504 "gnulib provides the I<realloc-posix> module, which provides wrappers "
505 "B<realloc>() and B<reallocarray>() that conform to all versions of ISO C "
506 "and POSIX.1."
507 msgstr ""
508
509 #. type: Plain text
510 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
511 #: opensuse-tumbleweed
512 msgid ""
513 "There's a proposal to standardize the BSD behavior: E<.UR https:\\://"
514 "www.open-std.org/\\:jtc1/\\:sc22/\\:wg14/\\:www/\\:docs/\\:n3621.txt> "
515 "E<.UE .>"
516 msgstr ""
517
518 #. type: SH
519 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
520 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
521 #, no-wrap
522 msgid "HISTORY"
523 msgstr ""
524
525 #. type: Plain text
526 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
527 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
528 msgid "POSIX.1-2001, C89."
529 msgstr ""
530
531 #. type: Plain text
532 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
533 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
534 msgid "glibc 2.26. OpenBSD 5.6, FreeBSD 11.0."
535 msgstr ""
536
537 #. type: Plain text
538 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
539 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
540 msgid ""
541 "B<malloc>() and related functions rejected sizes greater than "
542 "B<PTRDIFF_MAX> starting in glibc 2.30."
543 msgstr ""
544
545 #. type: Plain text
546 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
547 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
548 msgid "B<free>() preserved I<errno> starting in glibc 2.33."
549 msgstr ""
550
551 #. type: SS
552 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
553 #: opensuse-tumbleweed
554 #, no-wrap
555 msgid "realloc(p,\\ 0)"
556 msgstr ""
557
558 #. type: Plain text
559 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
560 #: opensuse-tumbleweed
561 msgid ""
562 "C89 was ambiguous in its specification of I<realloc(p,\\ 0)>. C99 partially "
563 "fixed this."
564 msgstr ""
565
566 #. type: Plain text
567 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
568 #: opensuse-tumbleweed
569 msgid ""
570 "The original implementation in glibc would have been conforming to C99. "
571 "However, and ironically, trying to comply with C99 before the standard was "
572 "released, glibc changed its behavior in glibc 2.1.1 into something that "
573 "ended up not conforming to the final C99 specification (but this is debated, "
574 "as the wording of the standard seems self-contradicting)."
575 msgstr ""
576
577 #. type: SH
578 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
579 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
580 #, no-wrap
581 msgid "NOTES"
582 msgstr ""
583
584 #. type: Plain text
585 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
586 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
587 msgid ""
588 "By default, Linux follows an optimistic memory allocation strategy. This "
589 "means that when B<malloc>() returns non-NULL there is no guarantee that the "
590 "memory really is available. In case it turns out that the system is out of "
591 "memory, one or more processes will be killed by the OOM killer. For more "
592 "information, see the description of I</proc/sys/vm/overcommit_memory> and I</"
593 "proc/sys/vm/oom_adj> in B<proc>(5), and the Linux kernel source file "
594 "I<Documentation/vm/overcommit-accounting.rst>."
595 msgstr ""
596
597 #. type: Plain text
598 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
599 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
600 msgid ""
601 "Normally, B<malloc>() allocates memory from the heap, and adjusts the size "
602 "of the heap as required, using B<sbrk>(2). When allocating blocks of memory "
603 "larger than B<MMAP_THRESHOLD> bytes, the glibc B<malloc>() implementation "
604 "allocates the memory as a private anonymous mapping using B<mmap>(2). "
605 "B<MMAP_THRESHOLD> is 128\\ kB by default, but is adjustable using "
606 "B<mallopt>(3). Prior to Linux 4.7 allocations performed using B<mmap>(2) "
607 "were unaffected by the B<RLIMIT_DATA> resource limit; since Linux 4.7, this "
608 "limit is also enforced for allocations performed using B<mmap>(2)."
609 msgstr ""
610
611 #. type: Plain text
612 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
613 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
614 msgid ""
615 "To avoid corruption in multithreaded applications, mutexes are used "
616 "internally to protect the memory-management data structures employed by "
617 "these functions. In a multithreaded application in which threads "
618 "simultaneously allocate and free memory, there could be contention for these "
619 "mutexes. To scalably handle memory allocation in multithreaded "
620 "applications, glibc creates additional I<memory allocation arenas> if mutex "
621 "contention is detected. Each arena is a large region of memory that is "
622 "internally allocated by the system (using B<brk>(2) or B<mmap>(2)), and "
623 "managed with its own mutexes."
624 msgstr ""
625
626 #. type: Plain text
627 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
628 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
629 msgid ""
630 "If your program uses a private memory allocator, it should do so by "
631 "replacing B<malloc>(), B<free>(), B<calloc>(), and B<realloc>(). The "
632 "replacement functions must implement the documented glibc behaviors, "
633 "including I<errno> handling, size-zero allocations, and overflow checking; "
634 "otherwise, other library routines may crash or operate incorrectly. For "
635 "example, if the replacement I<free>() does not preserve I<errno>, then "
636 "seemingly unrelated library routines may fail without having a valid reason "
637 "in I<errno>. Private memory allocators may also need to replace other glibc "
638 "functions; see \"Replacing malloc\" in the glibc manual for details."
639 msgstr ""
640
641 #. type: Plain text
642 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
643 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
644 msgid ""
645 "Crashes in memory allocators are almost always related to heap corruption, "
646 "such as overflowing an allocated chunk or freeing the same pointer twice."
647 msgstr ""
648
649 #. type: Plain text
650 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
651 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
652 msgid ""
653 "The B<malloc>() implementation is tunable via environment variables; see "
654 "B<mallopt>(3) for details."
655 msgstr ""
656
657 #. type: SS
658 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
659 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
660 #, no-wrap
661 msgid "Nonportable behavior"
662 msgstr ""
663
664 #. type: Plain text
665 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
666 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
667 msgid ""
668 "The behavior of these functions when the requested size is zero is glibc "
669 "specific; other implementations may return NULL without setting I<errno>, "
670 "and portable POSIX programs should tolerate such behavior. See "
671 "B<realloc>(3p)."
672 msgstr ""
673
674 #. type: Plain text
675 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
676 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
677 msgid ""
678 "POSIX requires memory allocators to set I<errno> upon failure. However, the "
679 "C standard does not require this, and applications portable to non-POSIX "
680 "platforms should not assume this."
681 msgstr ""
682
683 #. type: Plain text
684 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
685 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
686 msgid ""
687 "Portable programs should not use private memory allocators, as POSIX and the "
688 "C standard do not allow replacement of B<malloc>(), B<free>(), B<calloc>(), "
689 "and B<realloc>()."
690 msgstr ""
691
692 #. type: SH
693 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
694 #: opensuse-tumbleweed
695 #, no-wrap
696 msgid "BUGS"
697 msgstr ""
698
699 #. type: Plain text
700 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
701 #: opensuse-tumbleweed
702 msgid ""
703 "Programmers would naturally expect by induction that I<\\%realloc(p,\\ "
704 "size)> is consistent with I<free(p)> and I<malloc(size)>, as that is the "
705 "behavior in the general case. This is not explicitly required by "
706 "POSIX.1-2024 or C11, but all conforming implementations are consistent with "
707 "that."
708 msgstr ""
709
710 #. type: Plain text
711 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
712 #: opensuse-tumbleweed
713 msgid ""
714 "The glibc implementation of B<realloc>() is not consistent with that, and "
715 "as a consequence, it is dangerous to call I<\\%realloc(p,\\ 0)> in glibc."
716 msgstr ""
717
718 #. type: Plain text
719 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
720 #: opensuse-tumbleweed
721 msgid ""
722 "A trivial workaround for glibc is calling it as I<\\%realloc(p,\\ size?"
723 "size:1)>."
724 msgstr ""
725
726 #. type: Plain text
727 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
728 #: opensuse-tumbleweed
729 msgid ""
730 "The workaround for B<reallocarray>() in glibc \\[em]which shares the same "
731 "bug\\[em] would be I<\\%reallocarray(p,\\ n?n:1,\\ size?size:1)>."
732 msgstr ""
733
734 #. type: SH
735 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
736 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
737 #, no-wrap
738 msgid "EXAMPLES"
739 msgstr ""
740
741 #. type: Plain text
742 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
743 #: opensuse-leap-16-1 opensuse-tumbleweed
744 #, no-wrap
745 msgid ""
746 "#include E<lt>err.hE<gt>\n"
747 "#include E<lt>stddef.hE<gt>\n"
748 "#include E<lt>stdio.hE<gt>\n"
749 "#include E<lt>stdlib.hE<gt>\n"
750 "#include E<lt>string.hE<gt>\n"
751 "\\&\n"
752 "#define MALLOCARRAY(n, type) ((type *) my_mallocarray(n, sizeof(type)))\n"
753 "#define MALLOC(type) MALLOCARRAY(1, type)\n"
754 "\\&\n"
755 "static inline void *my_mallocarray(size_t n, size_t size);\n"
756 "\\&\n"
757 "int\n"
758 "main(void)\n"
759 "{\n"
760 " char *p;\n"
761 "\\&\n"
762 " p = MALLOCARRAY(32, char);\n"
763 " if (p == NULL)\n"
764 " err(EXIT_FAILURE, \"malloc\");\n"
765 "\\&\n"
766 " strlcpy(p, \"foo\", 32);\n"
767 " puts(p);\n"
768 "}\n"
769 "\\&\n"
770 "static inline void *\n"
771 "my_mallocarray(size_t n, size_t size)\n"
772 "{\n"
773 " return reallocarray(NULL, n, size);\n"
774 "}\n"
775 msgstr ""
776
777 #. type: SH
778 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
779 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
780 #, no-wrap
781 msgid "SEE ALSO"
782 msgstr ""
783
784 #. type: Plain text
785 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
786 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
787 msgid ""
788 "B<valgrind>(1), B<brk>(2), B<mmap>(2), B<alloca>(3), B<malloc_get_state>(3), "
789 "B<malloc_info>(3), B<malloc_trim>(3), B<malloc_usable_size>(3), "
790 "B<mallopt>(3), B<mcheck>(3), B<mtrace>(3), B<posix_memalign>(3)"
791 msgstr ""
792
793 #. type: Plain text
794 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
795 #: opensuse-tumbleweed
796 msgid ""
797 "For details of the GNU C library implementation, see E<.UR https:\\://"
798 "sourceware.org/glibc/wiki/MallocInternals> E<.UE .>"
799 msgstr ""
800
801 #. type: TH
802 #: debian-trixie
803 #, no-wrap
804 msgid "2024-05-02"
805 msgstr ""
806
807 #. type: TH
808 #: debian-trixie
809 #, no-wrap
810 msgid "Linux man-pages 6.9.1"
811 msgstr ""
812
813 #. type: Plain text
814 #: debian-trixie
815 msgid "Standard C library (I<libc>, I<-lc>)"
816 msgstr ""
817
818 #. type: Plain text
819 #: debian-trixie
820 #, no-wrap
821 msgid ""
822 "B<void *malloc(size_t >I<size>B<);>\n"
823 "B<void free(void *_Nullable >I<ptr>B<);>\n"
824 "B<void *calloc(size_t >I<nmemb>B<, size_t >I<size>B<);>\n"
825 "B<void *realloc(void *_Nullable >I<ptr>B<, size_t >I<size>B<);>\n"
826 "B<void *reallocarray(void *_Nullable >I<ptr>B<, size_t >I<nmemb>B<, size_t >I<size>B<);>\n"
827 msgstr ""
828
829 #. type: Plain text
830 #: debian-trixie fedora-44 fedora-rawhide
831 msgid ""
832 "The B<free>() function frees the memory space pointed to by I<ptr>, which "
833 "must have been returned by a previous call to B<malloc>() or related "
834 "functions. Otherwise, or if I<ptr> has already been freed, undefined "
835 "behavior occurs. If I<ptr> is NULL, no operation is performed."
836 msgstr ""
837
838 #. type: Plain text
839 #: debian-trixie
840 msgid ""
841 "The B<calloc>() function allocates memory for an array of I<nmemb> elements "
842 "of I<size> bytes each and returns a pointer to the allocated memory. The "
843 "memory is set to zero. If I<nmemb> or I<size> is 0, then B<calloc>() "
844 "returns a unique pointer value that can later be successfully passed to "
845 "B<free>()."
846 msgstr ""
847
848 #. type: Plain text
849 #: debian-trixie
850 msgid ""
851 "If the multiplication of I<nmemb> and I<size> would result in integer "
852 "overflow, then B<calloc>() returns an error. By contrast, an integer "
853 "overflow would not be detected in the following call to B<malloc>(), with "
854 "the result that an incorrectly sized block of memory would be allocated:"
855 msgstr ""
856
857 #. type: Plain text
858 #: debian-trixie
859 #, no-wrap
860 msgid "malloc(nmemb * size);\n"
861 msgstr ""
862
863 #. type: Plain text
864 #: debian-trixie fedora-44 fedora-rawhide
865 msgid ""
866 "The B<realloc>() function changes the size of the memory block pointed to "
867 "by I<ptr> to I<size> bytes. The contents of the memory will be unchanged in "
868 "the range from the start of the region up to the minimum of the old and new "
869 "sizes. If the new size is larger than the old size, the added memory will "
870 "I<not> be initialized."
871 msgstr ""
872
873 #. type: Plain text
874 #: debian-trixie fedora-44 fedora-rawhide
875 msgid ""
876 "If I<ptr> is NULL, then the call is equivalent to I<malloc(size)>, for all "
877 "values of I<size>."
878 msgstr ""
879
880 #. type: Plain text
881 #: debian-trixie fedora-44 fedora-rawhide
882 msgid ""
883 "If I<size> is equal to zero, and I<ptr> is not NULL, then the call is "
884 "equivalent to I<free(ptr)> (but see \"Nonportable behavior\" for portability "
885 "issues)."
886 msgstr ""
887
888 #. type: Plain text
889 #: debian-trixie fedora-44 fedora-rawhide
890 msgid ""
891 "Unless I<ptr> is NULL, it must have been returned by an earlier call to "
892 "B<malloc> or related functions. If the area pointed to was moved, a "
893 "I<free(ptr)> is done."
894 msgstr ""
895
896 #. type: Plain text
897 #: debian-trixie
898 msgid ""
899 "The B<reallocarray>() function changes the size of (and possibly moves) "
900 "the memory block pointed to by I<ptr> to be large enough for an array of "
901 "I<nmemb> elements, each of which is I<size> bytes. It is equivalent to the "
902 "call"
903 msgstr ""
904
905 #. type: Plain text
906 #: debian-trixie
907 #, no-wrap
908 msgid "realloc(ptr, nmemb * size);\n"
909 msgstr ""
910
911 #. type: Plain text
912 #: debian-trixie fedora-44 fedora-rawhide
913 msgid ""
914 "The B<realloc>() and B<reallocarray>() functions return NULL if I<ptr> is "
915 "not NULL and the requested size is zero; this is not considered an error. "
916 "(See \"Nonportable behavior\" for portability issues.) Otherwise, the "
917 "returned pointer may be the same as I<ptr> if the allocation was not moved "
918 "(e.g., there was room to expand the allocation in-place), or different from "
919 "I<ptr> if the allocation was moved to a new address. If these functions "
920 "fail, the original block is left untouched; it is not freed or moved."
921 msgstr ""
922
923 #. type: Plain text
924 #: debian-trixie fedora-44 fedora-rawhide
925 msgid "C11, POSIX.1-2008."
926 msgstr ""
927
928 #. type: Plain text
929 #: debian-trixie fedora-44 fedora-rawhide
930 msgid "None."
931 msgstr ""
932
933 #. type: Plain text
934 #: debian-trixie
935 #, no-wrap
936 msgid ""
937 "#include E<lt>err.hE<gt>\n"
938 "#include E<lt>stddef.hE<gt>\n"
939 "#include E<lt>stdio.hE<gt>\n"
940 "#include E<lt>stdlib.hE<gt>\n"
941 "#include E<lt>string.hE<gt>\n"
942 "\\&\n"
943 "#define MALLOCARRAY(n, type) ((type *) my_mallocarray(n, sizeof(type)))\n"
944 "#define MALLOC(type) MALLOCARRAY(1, type)\n"
945 "\\&\n"
946 "static inline void *my_mallocarray(size_t nmemb, size_t size);\n"
947 "\\&\n"
948 "int\n"
949 "main(void)\n"
950 "{\n"
951 " char *p;\n"
952 "\\&\n"
953 " p = MALLOCARRAY(32, char);\n"
954 " if (p == NULL)\n"
955 " err(EXIT_FAILURE, \"malloc\");\n"
956 "\\&\n"
957 " strlcpy(p, \"foo\", 32);\n"
958 " puts(p);\n"
959 "}\n"
960 "\\&\n"
961 "static inline void *\n"
962 "my_mallocarray(size_t nmemb, size_t size)\n"
963 "{\n"
964 " return reallocarray(NULL, nmemb, size);\n"
965 "}\n"
966 msgstr ""
967
968 #. type: Plain text
969 #: debian-trixie fedora-44 fedora-rawhide
970 msgid ""
971 "For details of the GNU C library implementation, see E<.UR https://"
972 "sourceware.org/glibc/wiki/MallocInternals> E<.UE .>"
973 msgstr ""
974
975 #. type: TH
976 #: fedora-44 fedora-rawhide
977 #, no-wrap
978 msgid "2024-11-17"
979 msgstr ""
980
981 #. type: TH
982 #: fedora-44 fedora-rawhide
983 #, no-wrap
984 msgid "Linux man-pages 6.13"
985 msgstr ""
986
987 #. type: Plain text
988 #: fedora-44 fedora-rawhide
989 #, no-wrap
990 msgid ""
991 "B<void *malloc(size_t >I<size>B<);>\n"
992 "B<void free(void *_Nullable >I<ptr>B<);>\n"
993 "B<void *calloc(size_t >I<n>B<, size_t >I<size>B<);>\n"
994 "B<void *realloc(void *_Nullable >I<ptr>B<, size_t >I<size>B<);>\n"
995 "B<void *reallocarray(void *_Nullable >I<ptr>B<, size_t >I<n>B<, size_t >I<size>B<);>\n"
996 msgstr ""
997
998 #. type: Plain text
999 #: fedora-44 fedora-rawhide
1000 msgid ""
1001 "The B<reallocarray>() function changes the size of (and possibly moves) "
1002 "the memory block pointed to by I<ptr> to be large enough for an array of "
1003 "I<n> elements, each of which is I<size> bytes. It is equivalent to the call"
1004 msgstr ""
1005
1006 #. type: Plain text
1007 #: fedora-44 fedora-rawhide
1008 #, no-wrap
1009 msgid "realloc(ptr, n * size);\n"
1010 msgstr ""
1011
1012 #. type: TH
1013 #: mageia-cauldron
1014 #, no-wrap
1015 msgid "Linux man-pages 6.17"
1016 msgstr ""
1017
1018 #. type: TH
1019 #: opensuse-leap-16-1 opensuse-tumbleweed
1020 #, no-wrap
1021 msgid "Linux man-pages (unreleased)"
1022 msgstr ""