Elamur Dictionary

malloc

English · noun; verb

Senses

Sense 1 · noun · corpus

corpus

A function in the C programming language that asks for space in the computer’s memory.

Source: Mova's open texts. Licence: cc-by-sa-4.0.

Forms and counts

Verb

  • Forms: malloc (VerbForm: Inf); malloced (Mood: Ind, Tense: Past, VerbForm: Fin); malloced (Tense: Past, VerbForm: Part); mallocing (VerbForm: Ger); mallocs (Mood: Ind, Number: Sing, Person: 3, Tense: Pres, VerbForm: Fin).

Noun

  • Forms: malloc (Number: Sing); mallocs (Number: Plur).
  • Seen 5 times in Mova's corpus index.

Usage and labels

corpus

The code asks for enough space to hold an array and checks whether the request failed. The other example discusses the pointer that malloc returns to tell the program where the space is.

Examples

5 source examples.

  • Dynamic memory allocation is performed using pointers; the result of a malloc is usually cast to the data type of the data to be stored. — Wikipedia: C (programming language) (Wikipedia contributors). Licence: cc-by-sa-4.0. — an example found by Mova's corpus index (cc-by-sa-4.0)
  • However, it is also possible to allocate a block of memory (of arbitrary size) at run time, using the standard library's malloc function, and treat it as an array. — Wikipedia: C (programming language) (Wikipedia contributors). Licence: cc-by-sa-4.0. — an example found by Mova's corpus index (cc-by-sa-4.0)
  • Dynamic memory allocation is performed using pointers; the result of a malloc is usually cast to the data type of the data to be stored. — Wikipedia: C (programming language) (Wikipedia contributors). Licence: cc-by-sa-4.0. — Mova's open texts (cc-by-sa-4.0)
  • However, it is also possible to allocate a block of memory (of arbitrary size) at run time, using the standard library's malloc function, and treat it as an array. — Wikipedia: C (programming language) (Wikipedia contributors). Licence: cc-by-sa-4.0. — Mova's open texts (cc-by-sa-4.0)
  • int func(int n, int m) { float (*p)[n][m] = malloc(sizeof *p); if (p == NULL) { return -1; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { (*p)[i][j] = i + j; } } print_array(n, m, p); free(p); return 1; } And here is a similar implementation using C99's Auto VLA feature: — Wikipedia: C (programming language) (Wikipedia contributors). Licence: cc-by-sa-4.0. — Mova's open texts (cc-by-sa-4.0)

Notes and derived forms

corpus

Sources

Mova's word records: counts from Mova's corpus index, word lists from Wiktionary and Mova's concept inventory. Licence: cc-by-sa-4.0.

Mova's open texts. Licence: cc-by-sa-4.0.

This page in Markdown https://md.dictionary.elamur.ai/free/en/english/malloc/