]> andersk Git - libfaim.git/blobdiff - aim_snac.c
- Thu Dec 14 03:39:34 UTC 2000
[libfaim.git] / aim_snac.c
index c6b005b9c47ee46fad0751859dac2a2228633744..ae46e47ed28b1af41fb51206c4439ca5ff611774 100644 (file)
@@ -30,6 +30,25 @@ faim_internal void aim_initsnachash(struct aim_session_t *sess)
   return;
 }
 
+faim_internal unsigned long aim_cachesnac(struct aim_session_t *sess,
+                                         const unsigned short family,
+                                         const unsigned short type,
+                                         const unsigned short flags,
+                                         const void *data, const int datalen)
+{
+  struct aim_snac_t snac;
+
+  snac.id = sess->snac_nextid++;
+  snac.family = family;
+  snac.type = type;
+  snac.flags = flags;
+
+  snac.data = malloc(datalen);
+  memcpy(snac.data, data, datalen);
+
+  return aim_newsnac(sess, &snac);
+}
+
 /*
  * Clones the passed snac structure and caches it in the
  * list/hash.
@@ -109,11 +128,12 @@ faim_internal struct aim_snac_t *aim_remsnac(struct aim_session_t *sess,
 faim_internal int aim_cleansnacs(struct aim_session_t *sess,
                                 int maxage)
 {
-  struct aim_snac_t *cur, *next, *prev = NULL;
-  time_t curtime;
   int i;
 
   for (i = 0; i < FAIM_SNAC_HASH_SIZE; i++) {
+    struct aim_snac_t *cur = NULL, *next = NULL, *prev = NULL;
+    time_t curtime;
+
     faim_mutex_lock(&sess->snac_hash_locks[i]);
     if (!sess->snac_hash[i]) {
       faim_mutex_unlock(&sess->snac_hash_locks[i]);
This page took 0.122109 seconds and 4 git commands to generate.