Skip to content
Snippets Groups Projects
Verified Commit 89e9706b authored by orestis.malaspin's avatar orestis.malaspin
Browse files

added 2024

parent 6011c6ad
No related branches found
No related tags found
No related merge requests found
Pipeline #36441 passed
---
title: "Allocation dynamique de mémoire"
date: "2024-12-03"
---
# Allocation dynamique de mémoire (1/8)
- La fonction `malloc`{.C} permet d'allouer dynamiquement (pendant l'exécution du programme) une zone de mémoire contiguë.
```C
#include <stdlib.h>
void *malloc(size_t size);
```
- `size`{.C} est la taille de la zone mémoire **en octets**.
- Retourne un pointeur sur la zone mémoire ou `NULL`{.C} en cas d'échec: **toujours vérifier** que la valeur retournée est `!= NULL`{.C}.
- Le *type* du retour est `void *`{.C} (un pointeur de type quelconque).
# Allocation dynamique de mémoire (2/8)
- Allocation *sur le tas* d'un type de base:
```C
int *val = malloc(sizeof(int)); // réserve 4 octets sur le tas
*val = 4; // les 4 octets contiennent la valeur 4
```
- Presque la même chose que:
```C
int val = 4; // ici l'allocation et l'initialisation
// sont faites en une fois mais se trouve sur
// le *tas* (mémoire managée automatiquement)
```
- Attention:
```C
int *val = 4; // Ca c'est très faux...
```
# Allocation dynamique de mémoire (3/9)
- On peut allouer et initialiser une `fraction_t`{.C}:
```C
fraction_t *frac = malloc(sizeof(fraction_t));
frac->num = 1;
frac->denom = -1;
```
- La zone mémoire **n'est pas** initialisée.
- Désallouer la mémoire explicitement, sinon **fuites mémoires**.
- Il faut connaître la **taille** des données à allouer.
![La représentation mémoire de `fraction_t` et fuites.](figs/pointer_struct_ok.svg){width=100%}
# Allocation dynamique de mémoire (4/9)
- La fonction `free()`{.C} permet de libérer une zone préalablement allouée avec `malloc()`{.C}.
```C
#include <stdlib.h>
void free(void *ptr);
```
- A chaque `malloc()`{.C} doit correspondre exactement un `free()`{.C}.
- Si la mémoire n'est pas libérée: **fuite mémoire** (l'ordinateur plante quand il y a plus de mémoire).
- Si la mémoire est **libérée deux fois**: *seg. fault*.
- Pour éviter les mauvaises surprises mettre `ptr`{.C} à `NULL`{.C} après
libération.
# Allocation dynamique de mémoire (5/9)
## Tableaux dynamiques
- Pour allouer un espace mémoire de 50 entiers: un tableau
```C
int *p = malloc(50 * sizeof(int));
for (int i = 0; i < 50; ++i) {
p[i] = 0;
}
```
## Arithmétique de pointeurs
- Parcourir la mémoire différemment qu'avec l'indexation
```C
int *p = malloc(50 * sizeof(int));
// initialize somehow
int a = p[7];
int b = *(p + 7); // on avance de 7 "int"
p[0] == *p; // le pointeur est le premier élément
```
# Allocation dynamique de mémoire (6/9)
## Arithmétique de pointeurs
![L'arithmétique des pointeurs.](figs/pointer_arithmetics.svg){width=100%}
## Quelle est la complexité de l'accès à une case d'un tableau?
. . .
$$
\mathcal{O}(1).
$$
# Allocation dynamique de mémoire (7/9)
## Pointeur de pointeur
- Tout comme une valeur a une adresse, un pointeur a lui-même une adresse:
```C
int a = 2;
int *b = &a;
int **c = &b;
```
- En effet, un pointeur est aussi une variable (une variable qui contient une adresse mémoire).
- Chaque `*`{.C} rajoute une indirection.
# Allocation dynamique de mémoire (8/9)
## Pointeur de pointeur
![Les références de pointeurs.](figs/double_pointeur.svg){height=100%}
# Allocation dynamique de mémoire (9/9)
- Avec `malloc()`, on peut allouer dynamiquement des tableaux de pointeurs:
```C
int **p = malloc(50 * sizeof(int*));
for (int i = 0; i < 50; ++i) {
p[i] = malloc(70 * sizeof(int));
}
int a = p[5][8]; // on indexe dans chaque dimension
```
- Ceci est une matrice (un tableau de tableaux).
# Tableau dynamique en argument d'une fonction
## Implémenter la fonction ci-dessous
```C
int32_t *p = malloc(50 * sizeof(*p));
initialize_to(p, 50, -1); // initialise un tableau à -1
free(p); // ne pas oublier
```
. . .
```C
void initialize_to(int32_t *p, size_t size, int32_t val) {
for (size_t i = 0; i < size; ++i) {
p[i] = val;
}
}
```
# Tableau dynamique retourné d'une fonction
## Implémenter la fonction ci-dessous
```C
// alloue un tableau de taille 50 et l'initialise à -1
int32_t *p = initialize_to(50, -1);
free(p); // ne pas oublier
```
. . .
```C
int32_t *initialize_to(size_t size, int32_t val) {
int32_t *p = malloc(size * sizeof(*p));
for (size_t i = 0; i < size; ++i) {
p[i] = val;
}
return p;
}
```
## Pourquoi on peut retourner un tableau dynamique et pas un statique?
. . .
* Le tableau est alloué sur le **tas** et non sur la **pile**.
* La mémoire est gérée manuellement sur le tas, automatiquement sur la pile.
# Les *sanitizers*
Problèmes mémoire courants:
* Dépassement de capacité de tableaux.
* Utilisation de mémoire non allouée.
* Fuites mémoire.
* Double libération.
Outils pour leur détection:
* Valgrind (outil externe).
* Sanitizers (ajouts de marqueurs à la compilation).
Ici on utilise les sanitizers (modification de la ligne de compilation, modifiez donc vos *Makefile*):
```bash
gcc -o main main.c -g -fsanitize=address -fsanitize=leak
```
**Attention:** Il faut également faire l'édition des liens avec les sanitizers.
# Questions
## Que fait le code suivant?
```C
int *p = malloc(50 * sizeof(int));
p[10] = 1;
```
. . .
* On alloue de la place pour 50 entiers.
* On initialise le 11ème élément du tableau à 1.
* Les autres éléments sont non-initialisés.
# Questions
## Que fait le code suivant?
```C
float *p = malloc(50);
p[20] = 1.3;
```
. . .
* On déclare un pointeur de floats de taille 50 octets.
* Mais il ne peut contenir que `50 / 4` floats (un float est composé de 32 bits).
* On dépasse la capacité de la mémoire allouée: comportement indéfini.
# Questions
* Soit le code suivant
```C
int *p = malloc(50 * sizeof(int));
for (int i = 0; i < 50; ++i) {
p[i] = 0;
}
```
* Le réécrire en utilisant uniquement l'arithmétique de pointeurs.
. . .
```C
int *p = malloc(50 * sizeof(int));
for (int i = 0; i < 50; ++i) {
*(p+i) = 0;
}
```
# Questions
## Que valent les expressions suivantes?
```C
in32_t *p = malloc(50 * sizeof(int32_t));
sizeof(p);
sizeof(*p);
(p + 20);
*(p + 20);
p[-1];
p[50];
7[p];
```
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="245.24887mm"
height="86.080841mm"
viewBox="0 0 245.24887 86.080843"
version="1.1"
id="svg8"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
sodipodi:docname="pointer_struct_ok.svg">
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="483.38263"
inkscape:cy="105.54084"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1884"
inkscape:window-height="1052"
inkscape:window-x="36"
inkscape:window-y="0"
inkscape:window-maximized="1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0">
<inkscape:grid
originy="-104.07588"
originx="12.489411"
type="xygrid"
id="grid819" />
</sodipodi:namedview>
<defs
id="defs2">
<marker
inkscape:isstock="true"
style="overflow:visible"
id="marker3314"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Lend">
<path
inkscape:connector-curvature="0"
transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3312" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="marker3284"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Lend">
<path
inkscape:connector-curvature="0"
transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3028" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="Arrow2Lstart"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Lstart">
<path
inkscape:connector-curvature="0"
transform="matrix(1.1,0,0,1.1,1.1,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3025" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="Arrow2Lend"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Lend">
<path
inkscape:connector-curvature="0"
transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8951" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="Arrow2Lend-7"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Lend">
<path
transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8951-5"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="Arrow2Lend-9"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Lend">
<path
transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8951-8"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="Arrow2Lend-7-2"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Lend">
<path
transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8951-5-8"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="Arrow2Lend-1"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Lend">
<path
transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path8951-3"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:isstock="true"
style="overflow:visible"
id="marker3284-4"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Lend">
<path
inkscape:connector-curvature="0"
transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3028-7" />
</marker>
</defs>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(12.489412,-106.8433)"
id="layer1"
inkscape:groupmode="layer"
inkscape:label="Layer 1">
<g
style="fill:none;stroke:#0000ff;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="g846-7-2"
transform="matrix(0.48784069,0,0,1,-44.968279,-20.032731)">
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#0000ff;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect821-3-5-2"
width="29.104166"
height="9.260417"
x="99.218758"
y="156.77083" />
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#0000ff;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect821-6-3-8"
width="29.104166"
height="9.260417"
x="128.32292"
y="156.77083" />
</g>
<g
style="fill:none;stroke:#0000ff;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="g846-5-1"
transform="matrix(0.48784069,0,0,1,-16.571887,-20.032726)">
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#0000ff;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect821-3-6-9"
width="29.104166"
height="9.260417"
x="99.218758"
y="156.77083" />
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#0000ff;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect821-6-2-4"
width="29.104166"
height="9.260417"
x="128.32292"
y="156.77083" />
</g>
<g
id="g1489"
transform="translate(-82.051746)">
<g
transform="matrix(0.4878407,0,0,1,93.949527,-20.032732)"
id="g846-7-2-6"
style="fill:none;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1">
<rect
y="156.77083"
x="99.218758"
height="9.260417"
width="29.104166"
id="rect821-3-5-2-7"
style="opacity:1;fill:none;fill-opacity:1;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
y="156.77083"
x="128.32292"
height="9.260417"
width="29.104166"
id="rect821-6-3-8-5"
style="opacity:1;fill:none;fill-opacity:1;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g>
<g
transform="matrix(0.4878407,0,0,1,122.34592,-20.032727)"
id="g846-5-1-9"
style="fill:none;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1">
<rect
y="156.77083"
x="99.218758"
height="9.260417"
width="29.104166"
id="rect821-3-6-9-1"
style="opacity:1;fill:none;fill-opacity:1;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
y="156.77083"
x="128.32292"
height="9.260417"
width="29.104166"
id="rect821-6-2-4-2"
style="opacity:1;fill:none;fill-opacity:1;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g>
</g>
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path2993"
d="M -1.3502974,178.91256 C -10.434806,165.66351 -12.664615,164.59117 0.16160744,145.99852"
style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker3284)" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path2993-6"
d="M -1.6432048,189.1699 C -12.064062,177.52447 -18.226203,141.46875 -3.5290926,116.46165"
style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker3284-4)" />
<g
id="g1518"
transform="translate(3.2072343)">
<g
transform="matrix(0.48784068,0,0,1,-23.535649,-49.569597)"
id="g846-7-2-5"
style="fill:none;stroke:#0000ff;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:0.7158648, 1.43172961;stroke-dashoffset:0;stroke-opacity:1">
<rect
y="156.77083"
x="99.218758"
height="9.260417"
width="29.104166"
id="rect821-3-5-2-6"
style="opacity:1;fill:none;fill-opacity:1;stroke:#0000ff;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:0.7158648, 1.43172961;stroke-dashoffset:0;stroke-opacity:1" />
<rect
y="156.77083"
x="128.32292"
height="9.260417"
width="29.104166"
id="rect821-6-3-8-9"
style="opacity:1;fill:none;fill-opacity:1;stroke:#0000ff;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:0.7158648, 1.43172961;stroke-dashoffset:0;stroke-opacity:1" />
</g>
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#0000ff;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:0.50000001, 1.00000003;stroke-dashoffset:0;stroke-opacity:1"
id="rect821-3-6-7-37"
width="14.198196"
height="9.260417"
x="-3.5290926"
y="107.20123" />
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#0000ff;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:0.50000001, 1.00000003;stroke-dashoffset:0;stroke-opacity:1"
id="rect821-6-2-3-4"
width="14.198196"
height="9.260417"
x="10.669104"
y="107.20123" />
<g
transform="translate(-85.25898)"
id="g1481">
<g
style="fill:none;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:0.71586478, 1.43172956;stroke-dashoffset:0;stroke-opacity:1"
id="g846-7-2-6-4"
transform="matrix(0.48784071,0,0,1,90.258825,-49.569599)">
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:0.71586478, 1.43172956;stroke-dashoffset:0;stroke-opacity:1"
id="rect821-3-5-2-7-3"
width="29.104166"
height="9.260417"
x="99.218758"
y="156.77083" />
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:0.71586478, 1.43172956;stroke-dashoffset:0;stroke-opacity:1"
id="rect821-6-3-8-5-0"
width="29.104166"
height="9.260417"
x="128.32292"
y="156.77083" />
</g>
<g
style="fill:none;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:0.71586478, 1.43172956;stroke-dashoffset:0;stroke-opacity:1"
id="g846-5-1-9-8"
transform="matrix(0.48784071,0,0,1,118.65522,-49.569594)">
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:0.71586478, 1.43172956;stroke-dashoffset:0;stroke-opacity:1"
id="rect821-3-6-9-1-4"
width="29.104166"
height="9.260417"
x="99.218758"
y="156.77083" />
<rect
style="opacity:1;fill:none;fill-opacity:1;stroke:#ff0007;stroke-width:0.71586478;stroke-miterlimit:4;stroke-dasharray:0.71586478, 1.43172956;stroke-dashoffset:0;stroke-opacity:1"
id="rect821-6-2-4-2-3"
width="29.104166"
height="9.260417"
x="128.32292"
y="156.77083" />
</g>
</g>
</g>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:9.61108494px;line-height:1.25;font-family:monospace;-inkscape-font-specification:monospace;letter-spacing:0px;word-spacing:0px;stroke-width:0.24027713"
x="2.3449361"
y="132.47079"
id="text1455"><tspan
sodipodi:role="line"
id="tspan1453"
x="2.3449361"
y="132.47079"
style="stroke-width:0.24027713">fraction_t</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.58333302px;line-height:1.25;font-family:monospace;-inkscape-font-specification:monospace;letter-spacing:0px;word-spacing:0px;stroke-width:0.26458332"
x="2.2523637"
y="155.76122"
id="text1459"><tspan
sodipodi:role="line"
id="tspan1457"
x="2.2523637"
y="155.76122"
style="stroke-width:0.26458332">num</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.58333302px;line-height:1.25;font-family:monospace;-inkscape-font-specification:monospace;letter-spacing:0px;word-spacing:0px;stroke-width:0.26458332"
x="59.490494"
y="155.76122"
id="text1463"><tspan
sodipodi:role="line"
id="tspan1461"
x="59.490494"
y="155.76122"
style="stroke-width:0.26458332">denom</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.47521019px;line-height:1.25;font-family:monospace;-inkscape-font-specification:monospace;letter-spacing:0px;word-spacing:0px;stroke-width:0.21188024"
x="0.21260698"
y="181.14244"
id="text1467"><tspan
sodipodi:role="line"
id="tspan1465"
x="0.21260698"
y="181.14244"
style="stroke-width:0.21188024">fraction_t *frac = malloc(sizeof(fraction_t));</tspan><tspan
sodipodi:role="line"
x="0.21260698"
y="191.73645"
style="stroke-width:0.21188024"
id="tspan1471">frac = NULL; // addresse mémoire inaccessible</tspan></text>
</g>
</svg>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment