@matheusbsbs / matheus-bagliano / commits / 2626b53670
Fork 0

Notes API: add_note(): Add note objects to the internal notes tree structure

Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johan Herland committed Feb 13, 2010 at 22:28 UTC 2626b5367047d8b8d5c4555ec6b579ed37a6625d
2 files changed +15
notes.c
+11
@@ -368,6 +368,17 @@ void init_notes(const char *notes_ref, int flags)
368 load_subtree(&root_tree, &root_node, 0);
369 }
370
371 +void add_note(const unsigned char *object_sha1, const unsigned char *note_sha1)
372 +{
373 + struct leaf_node *l;
374 +
375 + assert(initialized);
376 + l = (struct leaf_node *) xmalloc(sizeof(struct leaf_node));
377 + hashcpy(l->key_sha1, object_sha1);
378 + hashcpy(l->val_sha1, note_sha1);
379 + note_tree_insert(&root_node, 0, l, PTR_TYPE_NOTE);
380 +}
381 +
382 static unsigned char *lookup_notes(const unsigned char *object_sha1)
383 {
384 struct leaf_node *found = note_tree_find(&root_node, 0, object_sha1);
notes.h
+4
@@ -21,6 +21,10 @@
21 */
22 void init_notes(const char *notes_ref, int flags);
23
24 +/* Add the given note object to the internal notes tree structure */
25 +void add_note(const unsigned char *object_sha1,
26 + const unsigned char *note_sha1);
27 +
28 /* Free (and de-initialize) the internal notes tree structure */
29 void free_notes(void);
30