forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1728822
committed
Expand palloc/pg_malloc API for more type safety
This adds additional variants of palloc, pg_malloc, etc. thatencapsulate common usage patterns and provide more type safety.Specifically, this adds palloc_object(), palloc_array(), andrepalloc_array(), which take the type name of the object to beallocated as its first argument and cast the return as a pointer tothat type. There are also palloc0_object() and palloc0_array()variants for initializing with zero, and pg_malloc_*() variants of allof the above.Inspired by the talloc library.This is backpatched from master so that future backpatchable code canmake use of these APIs. This patch by itself does not contain anyusers of these APIs.Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://www.postgresql.org/message-id/flat/bb755632-2a43-d523-36f8-a1e7a389a907@enterprisedb.com1 parent9394fe0 commit1728822
2 files changed
+50
-0
lines changedLines changed: 28 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
32 | 54 |
| |
33 | 55 |
| |
34 | 56 |
| |
| |||
38 | 60 |
| |
39 | 61 |
| |
40 | 62 |
| |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
41 | 69 |
| |
42 | 70 |
| |
43 | 71 |
| |
|
Lines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
80 | 80 |
| |
81 | 81 |
| |
82 | 82 |
| |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
83 | 105 |
| |
84 | 106 |
| |
85 | 107 |
| |
|
0 commit comments
Comments
(0)