static int rcd_prepend_rebindings()

in rcd_fishhook/rcd_fishhook.c [50:67]


static int rcd_prepend_rebindings(struct rcd_rebindings_entry **rebindings_head,
                              struct rcd_rebinding rebindings[],
                              size_t nel) {
  struct rcd_rebindings_entry *new_entry = (struct rcd_rebindings_entry *) malloc(sizeof(struct rcd_rebindings_entry));
  if (!new_entry) {
    return -1;
  }
  new_entry->rebindings = (struct rcd_rebinding *) malloc(sizeof(struct rcd_rebinding) * nel);
  if (!new_entry->rebindings) {
    free(new_entry);
    return -1;
  }
  memcpy(new_entry->rebindings, rebindings, sizeof(struct rcd_rebinding) * nel);
  new_entry->rebindings_nel = nel;
  new_entry->next = *rebindings_head;
  *rebindings_head = new_entry;
  return 0;
}