Skip to content

Instantly share code, notes, and snippets.

C lifetime and ownership documentation

Goals

  • Provide a guide for how and when to document lifetime and ownership in C
  • Prevent bugs caused by wrong assumptions of API users
  • Prevent having to read and understand the whole library code when the API user notices the lack of documentation.
  • Make it more likely that library developers notice a change lifetime requirements. They should check if the documentation is still correct after their change.

Non-Goals

@M1cha
M1cha / SAFER_C.md
Last active July 8, 2022 08:30
safe(r) C

Safe(r) C

Copy structs

If possible, use the assignment operator instead of memcpy:

struct s *s1;
struct s *s2;

*s1 = *s2;
@M1cha
M1cha / designer.html
Created January 7, 2015 19:12
designer
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@M1cha
M1cha / designer.html
Last active August 29, 2015 14:08
designer
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@M1cha
M1cha / designer.html
Created November 5, 2014 20:40
designer
<link rel="import" href="../topeka-elements/category-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;